- 0133技术站
- 联系QQ:88526
- QQ交流群

- 微信公众号

定义
scope 属性定义将表格中表头单元与数据单元相关联的方法。
scope 属性标识某个单元是否是列、行、列组或行组的表头。
scope 属性不会在普通浏览器中产生任何视觉变化。屏幕阅读器可以利用该属性。
详细解释
使用 scope 属性,可以将数据单元格与表头单元格联系起来。
通过属性值 row,表头行包括的所有表格都将和表头单元格联系起来。指定 col,会将当前列的所有单元格和表头单元格绑定起来。
使用 rowgroup 和 colgroup 会将单元格的行组(由 <thead>、<tbody> 或 <tfoot> 标签定义)或列组中的所有单元格和表头单元格绑定起来(由 <col> 或 <colgroup> 标签定义)。
注:HTML5 不支持 <td> scope 属性。
语法
<td scope="col|row|colgroup|rowgroup">
属性值
● col:规定单元格是列的表头。
● row:规定单元格是行的表头。
● colgroup:规定单元格是列组的表头。
● rowgroup:规定单元格是行组的表头。
浏览器支持
属性 | ![]() | ![]() | ![]() | ![]() | ![]() |
scope | 支持 | 支持 | 支持 | 支持 | 支持 |
scope 属性在普通的 Web 浏览器中没有视觉效果,但可以通过屏幕阅读器使用。
下面的实例把两个 <th> 元素标识为列的表头,把两个 <th> 元素标识为行的表头:
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>0133技术站(0133.cn)</title> </head> <body> <table border="1"> <tr> <th></th> <th scope="col">商品</th> <th scope="col">价格</th> </tr> <tr> <td>1</td> <td>T恤</td> <td>¥60.00</td> </tr> <tr> <td>2</td> <td>夹克</td> <td>¥150.00</td> </tr> </table> </body> </html>
点击 "运行实例" 按钮查看在线实例
推荐手册