<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属性
<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
<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
<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属性同时定义了行的表头和列的表头:
<table summary="The number of employees and the foundation year of some imaginary companies."> <caption>Table 1: Company data</caption> <tr> <th scope="col">Company</th> <th scope="col">Employees</th> <th scope="col">Founded</th> </tr> <tr> <td scope="row">ACME Inc</td> <td>1000</td> <td>1947</td> </tr> <tr> <td scope="row">XYZ Corp</td> <td>2000</td> <td>1973</td> </tr> </table> 这样的话可视化浏览器不会默认的把company name显示为表头。所以需要用CSS来修正一下,就刚才那个例子,我使用了下面的CSS:
Tables in HTML documents CSS formatting of tables Techniques for Accessible HTML Tables Building accessible websites: Tables and frames A table, s’il vous plaît