HTML表格详细介绍

1、表格只有行和单元格没有列的说法,其中<tr>表示行,<td>表示单元格或者理解为列也行。 <th>表示表头标签,起到加粗和居中作用

2、border、cellspacing、cellpadding合称三参,默认为值为0

3、cellspacing表示单元格与表框的距离与单元格的距离,cellpadding表示单元格的大小 和内容和单元格的距离,两者都是默认大小为2

4、<thead>表示表头部分,<tbody>表身体部分。其实也没什么用,就是划分模块的作用。

5、rowspan跨行合并,colspan跨列合并。合并顺序,先上后下,先左后右。

6、表格居中align="center"还有参数左右left、right

7、<caption>标题标签,能与表格合为一体。

 

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
</head>
<body>
<table width="500" border="1" align="center" cellspacing="10" cellpadding="20">
<caption><h4>表格的标题</h4></caption>
<thead align="center">
<th>头标题</th>
<th>头标题</th>
<th>头标题</th>
</thead>
<tbody>
<tr>
<td rowspan="2">姓名</td><!--跨行合并-->
<td>性别</td>
<td>地址</td>
</tr>
<tr>
<td align="center">姓名</td>
<td>地址</td>
</tr>
<tr>
<td colspan="2">性别</td> <!--跨列合并-->
<td>姓名</td>
</tr>
<tr>
<td>哈哈</td>
<td>哈哈</td>
<td>哈哈</td>
</tr>
</tbody>
</table>
</body>
</html>

最终效果图

posted @ 2019-03-31 22:22  showTimehzy  阅读(889)  评论(0编辑  收藏  举报