看起来(不管怎么说,根据this page上的例子)如果你使用的是THEAD,你就不需要使用TH。
这是真的吗?如果是这样的话,THEAD与TH的优缺点是什么?
发布于 2016-01-04 19:03:03
当您想要将一个单元格标记为标题单元格时,<th>
实际上是<td>
的替代品。
如果你想使用<thead>
和<th>
,别忘了在<tr>
中嵌套<th>
。否则代码可能无效。
示例:
<table>
<thead>
<tr>
<!-- scope="col" is optional if the th is inside a thead -->
<th scope="col">Season</th>
<th scope="col">Goals</th>
<th scope="col">Assists</th>
</tr>
</thead>
<tbody>
<tr>
<!-- scope="row" indicates that the th is a header for that row -->
<th scope="row">2009-2010</th>
<td>25</td>
<td>43</td>
</tr>
<tr>
<th scope="row">2011-2012</th>
<td>40</td>
<td>20</td>
</tr>
</tbody>
</table>
发布于 2014-09-08 21:07:35
与可能驻留在thead
内部的内容相比,th
更加具体。th
单元用于指定相应td
单元的报头。实际上,您可以向td
单元格添加headers
属性,该属性指向th
单元格的id (用于屏幕阅读器)。因此,th
与该列的td
直接相关。
但是,thead
可以包含任何标题,是的,它确实包含th
单元格,但它也可以包含您认为合适的任何内容,作为表格顶部的信息(不包括标题,因为它也有自己的标记)。
发布于 2011-03-23 01:25:23
<thead>
的特殊之处在于,它可以用于在打印版本中重复页面顶部的标题行。
https://stackoverflow.com/questions/5395228
复制相似问题