关于html 制作table的一个注意点

数据分析,一般都需要显示数据,就需要使用html做复杂的表格。复杂表格一般是对td的rowspan 、colspan属性值。

在html中<td> 标签定义 HTML 表格中的标准单元格。

  (1)rowspan 属性规定单元格可横跨的行数;

  (2)colspan 属性规定单元格可横跨的列数。

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title>复杂表格</title>
</head>
<body>
    <center>
        <table width = "20%" border="1">
            <tr>
                <th>网站</th>
                <th colspan="2">统计情况</th>    <!-- colspan="2"  占位,表示这一列占2列 -->
            </tr>
            <tr>
                <td rowspan="3">奇虎360</td>    <!-- rowspan="2"  占位,表示这一列占3行 -->
                <td>http://hao.360.cn/</td>
                <td>11</td>
            </tr>
            <tr>
                <td>http://sh.qihoo.com/</td>
                <td>22</td>
            </tr>
            <tr>
                <td>http://video.so.com/</td>
                <td>33</td>
            </tr>
        </table>                                                                                                                                                                                                           
    </center>
</body>
</html>

 

显示效果

 

rowspan 、colspan 可以理解为占位。占行数、列数。

posted @ 2017-05-10 15:31  你也很优秀  阅读(791)  评论(0编辑  收藏  举报