作者:龙犊整理
来源:天极
热度:
2006-10-5 11:56:03
sumary属性的内容不会被可视化浏览器显示,所以可以尽可能的让描述足够长,使得那些用“听”的浏览者了解表格的内容。当然也不要用过头了,当有需要的时候才加上summary属性,比如对于很复杂的表格,添加一个summary属性可以使用屏幕阅读器人比较简单的了解表格的内容。
<table summary="The number of employees and the foundation year of some imaginary companies.">
<caption>Table 1: Company data</caption>
<tr>
<th>Company</th>
<th>Employees</th>
<th>Founded</th>
</tr>
<tr>
<td>ACME Inc</td>
<td>1000</td>
<td>1947</td>
</tr>
<tr>
<td>XYZ Corp</td>
<td>2000</td>
<td>1973</td>
</tr>
</table>
缩写表头:abbr属性
当屏幕阅读器遇到一个表格,每一行会把表头连每一个数据单元格一起读出来。如果表头很长,听一遍一遍的读是十分乏味的。通过使用abbr属性,可以给那些长的表头提供简写形式,取代表头的内容。abbr属性是可选的,大部分情况表头还是(或许是应该)比较简短的。
稍微修改一下刚才的表格,让表头更长些,abbr属性就可以这样用:
<table summary="The number of employees and the foundation year of some imaginary companies.">
<caption>Table 1: Company data</caption>
<tr>
<th abbr="Company">Company Name</th>
<th abbr="Employees">Number of Employees</th>
<th abbr="Founded">Foundation Year</th>
</tr>
<tr>
<td>ACME Inc</td>
<td>1000</td>
<td>1947</td>
</tr>
<tr>
<td>XYZ Corp</td>
<td>2000</td>
<td>1973</td>
</tr>
</table>
Table 1: Company data Company Name Number of Employees Foundation Year
ACME Inc 1000 1947
XYZ Corp 2000 1973
对于第一行数据,屏幕阅读器会读表头的全称,而从第二行开始即使用简称。
这样让数据表格适应布局是挺困难的,而以下的做法更为常见:即让表头尽可能的短,或者简写,使用title属性或者<abbr>标签提供一个更长的说明。
把表头和数据联系起来:scope,id,headers属性
就我用到现在,很多表格要比上面提供的例子复杂的多。让例子复杂一点,我会移去“Company”表头,并且把第一列的数据移到表头单元格里:
<table summary="The number of employees and the foundation year of some imaginary companies.">
<caption>Table 1: Company data</caption>
<tr>
<td></td>
<th>Employees</th>
<th>Founded</th>
</tr>
<tr>
<th>ACME Inc</th>
<td>1000</td>
<td>1947</td>
</tr>
<tr>
<th>XYZ Corp</th>
<td>2000</td>
<td>1973</td>
</tr>
</table>
Table 1: Company data Employees Founded
ACME Inc 1000 1947
XYZ Corp 2000 1973
在这个表格里,每一个数据单元格都有两个表头。最简单的方法让那些非可视的浏览器理解这个表格,就是为每个表头添加一个scope属性。
<table summary="The number of employees and the foundation year of some imaginary companies.">
<caption>Table 1: Company data</caption>
<tr>
<td></td>
<th scope="col">Employees</th>
<th scope="col">Founded</th>
</tr>
<tr>
<th scope="row">ACME Inc</th>
<td>1000</td>
<td>1947</td>
</tr>
<tr>
<th scope="row">XYZ Corp</th>
<td>2000</td>
<td>1973</td>
</tr>
</table>
Scope属性同时定义了行的表头和列的表头:
我来说两句:
推荐文章
相关文章