HTML td scope 屬性
實例
下面的實例把兩個<th> 元素標識為列的表頭,把兩個<th> 元素標識為行的表頭:
<table border="1">
<tr>
<th></th>
<th scope="col">Month</th>
<th scope="col">Savings</th>
</tr>
<tr>
<td scope="row">1</td>
<td>January</td>
<td>$100</td>
</tr>
<tr>
<td scope="row">2</td>
<td>February</td>
<td>$80</td>
</tr>
</table>
<tr>
<th></th>
<th scope="col">Month</th>
<th scope="col">Savings</th>
</tr>
<tr>
<td scope="row">1</td>
<td>January</td>
<td>$100</td>
</tr>
<tr>
<td scope="row">2</td>
<td>February</td>
<td>$80</td>
</tr>
</table>
嘗試一下»
瀏覽器支持
scope 屬性在普通的Web 瀏覽器中沒有視覺效果,但可以通過屏幕閱讀器使用。
定義和用法
HTML5不支持<td> scope屬性。
scope 屬性定義將表格中表頭單元與數據單元相關聯的方法。
scope 屬性標識某個單元是否是列、行、列組或行組的表頭。
語法
<td scope="col|row|colgroup|rowgroup">
屬性值
值 | 描述 |
---|---|
col | 规定单元格是列的表头。 |
row | 规定单元格是行的表头。 |
colgroup | 规定单元格是列组的表头。 |
rowgroup | 规定单元格是行组的表头。 |
HTML <td>標籤