Skip to content

Latest commit

 

History

History
77 lines (61 loc) · 1.69 KB

File metadata and controls

77 lines (61 loc) · 1.69 KB

HTML headers 属性

定义和用法

headers 属性指定一个或多个与表格单元格相关的标题单元格。

适用于

headers 属性可用于以下元素:

元素 Element 属性 Attribute
<td> headers
<th> headers

示例

Td 示例

指定每个 <td> 元素相关的 <th> 元素:

<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 示例

指定每个标题单元格相关的 <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 chrome edge firefox safari opera
<td> Yes Yes Yes Yes Yes
<th> Yes Yes Yes Yes Yes