Tables
Accessible tables and media ensure that all users, including those using assistive technologies, can understand, navigate, and operate your content. For tables, use semantic structure to expose relationships between headers and data. For media, always provide user controls and alternatives like captions or transcripts.
Examplesβ
β Correct
<table>
<caption>Quarterly Sales Report</caption>
<thead>
<tr>
<th scope="col">Quarter</th>
<th scope="col">Product A</th>
<th scope="col">Product B</th>
<th scope="col">Total</th>
</tr>
</thead>
<tbody>
<tr>
<th scope="row">Q1</th>
<td>120</td>
<td>90</td>
<td>210</td>
</tr>
<tr>
<th scope="row">Q2</th>
<td>150</td>
<td>110</td>
<td>260</td>
</tr>
</tbody>
</table>
β Incorrect
<table border="1">
<tr>
<td colspan="4">Quarterly Sales Report</td>
</tr>
<tr style="background: green;">
<td>Q1</td>
<td>120</td>
<td>90</td>
<td>210</td>
</tr>
<tr style="background: red;">
<td>Q2</td>
<td>150</td>
<td>110</td>
<td>260</td>
</tr>
</table>