创建基本表格结构
首先创建一个包含表头(table header)、表体(table body)和表尾(table footer)部分的基本表格结构。
<!doctype html>
<html>
<head>
<title>Table Footer using tfoot Tag</title>
</head>
<body>
<table>
<thead>
<tr>
<th>Name</th>
<th>Age</th>
<th>Gender</th>
</tr>
</thead>
<tbody>
<tr>
<td>John</td>
<td>35</td>
<td>Male</td>
</tr>
<tr>
<td>Jane</td>
<td>28</td>
<td>Female</td>
</tr>
<tr>
<td>David</td>
<td>42</td>
<td>Male</td>
</tr>
</tbody>
<tfoot>
<tr>
<td colspan="3">Table Footer</td>
</tr>
</tfoot>
</table>
</body>
</html>
在上面的代码中,我们创建了一个包含三列(Name、Age 和 Gender)的基本表格结构,并添加了三行数据。<tfoot>
标签中只包含一行,其中有一个单元格(<td>
),该单元格横跨三列(colspan="3"
)。