html - 辅助功能:如何配置“列标题”公告?
问题描述
我正在为视障人士优化网站。我在页面上有一个表格,格式如下 -
<table>
<thead>
<tr>
<th>Number</th>
<th>Name</th>
<th>Surname</th>
</tr>
</thead>
<tbody>
...
</tbody>
</table>
目前,屏幕阅读器正在宣布“row 1 col 1 number”,但期望它应该在其元素时宣布“row 1 col 1 number column header ”。我该如何配置它?设置 role="columnheader" 不起作用。
解决方案
您scope
正在寻找关联列和行。
scope="col"
将表标题关联为列标题。
如果您愿意,还可以关联行标题scope="row"
<table>
<caption>My table caption - don't forget this so people know what a table is for / about</caption>
<thead>
<tr>
<th scope="col">Number</th>
<th scope="col">Name</th>
<th scope="col">Surname</th>
</tr>
</thead>
<tbody>
<tr>
<td scope="row">1</td>
<td>John</td>
<td>Smith</td>
</tr>
<tr>
<td scope="row">2</td>
<td>Mike</td>
<td>Simmons</td>
</tr>
</tbody>
</table>
有关此技术的更多信息,请参阅https://www.w3.org/TR/WCAG20-TECHS/H63.html。
ps不要忘记在<caption>
您的表格中添加a!
推荐阅读
- python - 将 softmax 应用于矩阵中跨维度的非零元素
- python - 为什么我无法在给定位置存储我的价值
- excel - Excel ActiveX 组合框显示以前的值问题
- java - 尝试在我的浏览器中查看 pdf 文件时,PDF 被呈现为文本内容
- c++ - Check that signature of two functions or member function pointer equal
- macos - Mono.framework is missing on my mac ... but it's... there?
- django - 在 django 中提供静态文件以进行图像处理
- c# - Assets/line_genertaor.cs(9,5):错误 CS0246:找不到类型或命名空间名称“Line”。您是否缺少程序集参考?
- string-formatting - QString::number 如果数字为正,则用零填充
- c - 仅解析给定参数中的数字