headers 属性指定一个或多个与表格单元格相关的标题单元格。
headers 属性可用于以下元素:
| 元素 Element | 属性 Attribute |
|---|---|
| <td> | headers |
| <th> | headers |
<style>
table, th, td { border: 1px solid black; }
</style>
<table>
<tr>
<th>姓名</th>
<th>邮箱</th>
<th>电话</th>
</tr>
<tr>
<td>周杰伦</td>
<td>zhou@example.com</td>
<td>123-45-678</td>
</tr>
</table>指定每个标题单元格相关的 <th> 元素:
<style>
table, th, td { border: 1px solid black; }
</style>
<table>
<tr>
<th id="name" colspan="2">姓名</th>
</tr>
<tr>
<th headers="name">名</th>
<th headers="name">姓</th>
</tr>
</table>headers 属性对每个元素都有以下浏览器支持:
| 元素 Element | |||||
|---|---|---|---|---|---|
| <td> | Yes | Yes | Yes | Yes | Yes |
| <th> | Yes | Yes | Yes | Yes | Yes |