XHTML tables should not be used for layout. For marking up tabular data, however, tables are what should be used. To make data tables as accessible as possible it is important to know about and use the various components that can make up a table. A few examples are table headings (<th>
), summaries (the summary
attribute), and captions (the <caption>
element).
<table class="example" summary="This table shows the annual population increase in Sweden during the years 1999 to 2003."> <caption>Annual population increase in Sweden, 1999–2003</caption> <thead> <tr> <td> </td> <th scope="col">1999</th> <th scope="col">2000</th> <th scope="col">2001</th> <th scope="col">2002</th> <th scope="col">2003</th> </tr> </thead> <tbody> <tr> <th>Population</th> <td scope="row">8 861 426</td> <td scope="row">8 882 792</td> <td scope="row">8 909 128</td> <td scope="row">8 940 788</td> <td scope="row">8 975 670</td> </tr> <tr> <th>Increase</th> <td scope="row">7 104</td> <td scope="row">21 366</td> <td scope="row">26 368</td> <td scope="row">31 884</td> <td scope="row">34 882</td> </tr> </tbody> </table>
1999 | 2000 | 2001 | 2002 | 2003 | |
---|---|---|---|---|---|
Population | 8 861 426 | 8 882 792 | 8 909 128 | 8 940 788 | 8 975 670 |
Increase | 7 104 | 21 366 | 26 368 | 31 884 | 34 882 |