HTML5中的表格
第四步:用 scope 明确表头的范围
scope 的英文意思是“范围”,它是 th 的属性,不是新标签。
- scope="col":col是Column(列)的缩写,表示列方向的表头。
- scope="row":row表示行,说明这是行方向的表头。
<table>
<caption>前两次理论课的学时</caption>
<thead>
<tr>
<th scope="col">主题</th>
<th scope="col">学时</th>
</tr>
</thead>
<tbody>
<tr>
<th scope="row">网页设计基础</th>
<td>2</td>
</tr>
<tr>
<th scope="row">初识HTML5</th>
<td>2</td>
</tr>
</tbody>
<tfoot>
<tr>
<th scope="row">合计</th>
<td>4</td>
</tr>
</tfoot>
</table>
同一个“2”,通过行表头确定属于哪次课,通过列表头确定表示学时。添加scope后外观可以完全不变,因为它表达关系,不负责样式。