HTML5中的表格
第三步:给表格命名,并组织各行
数据保持不变,加入表题、行分组和一行汇总。
- caption — Caption(标题说明):表题,放在table内的开头。
- thead — Table Head(表头行分组):包住表头区域的行。
- tbody — Table Body(表格主体):包住主要数据行。
- tfoot — Table Foot(表尾行分组):这里包住汇总行。
<table>
<caption>前两次理论课的学时</caption>
<thead>
<tr>
<th>主题</th>
<th>学时</th>
</tr>
</thead>
<tbody>
<tr>
<th>网页设计基础</th>
<td>2</td>
</tr>
<tr>
<th>初识HTML5</th>
<td>2</td>
</tr>
</tbody>
<tfoot>
<tr>
<th>合计</th>
<td>4</td>
</tr>
</tfoot>
</table>
行分组内部仍是tr,再由tr包含th或td。合计4是手动填写的,tfoot不会自动求和;这些元素也不负责自动画边框。