Performance: Table accessibility basics
This affects page load speed slightly but mainly impacts user experience and visual stability for screen readers and keyboard users.
<table> <thead> <tr><th scope="col">Header 1</th><th scope="col">Header 2</th></tr> </thead> <tbody> <tr><td>Data 1</td><td>Data 2</td></tr> </tbody> </table>
<table> <tr><td>Header 1</td><td>Header 2</td></tr> <tr><td>Data 1</td><td>Data 2</td></tr> </table>
| Pattern | DOM Operations | Reflows | Paint Cost | Verdict |
|---|---|---|---|---|
| Using <td> for headers without scope | Minimal | 0 | 0 | [X] Bad |
| Using <th> with scope and <thead>/<tbody> | Minimal | 0 | 0 | [OK] Good |
<caption> element in an HTML table?<caption><caption> element is used to give a title or description to a table, which helps screen readers and users understand the table's content.<caption> provides a descriptive title.<caption> = Table title [OK]<th> element is used for header cells, not <td>.scope="col" is correct. <th scope="col">Header</th> uses <th scope="col">, which is the proper syntax.<th scope="col"> = Column header [OK]<table>
<caption>User List</caption>
<thead>
<tr>
<th scope="col">Name</th>
<th scope="col">Age</th>
</tr>
</thead>
<tbody>
<tr>
<td>Alice</td>
<td>30</td>
</tr>
</tbody>
</table>scope="col" attribute on the <th> means the header applies to the entire column below it.<table>
<tr>
<td>Product</td>
<td>Price</td>
</tr>
<tr>
<td>Book</td>
<td>$10</td>
</tr>
</table><caption>, which helps describe the table for screen readers.<td> instead of <th> for headers, and no scope attributes are present.<caption> for table description<th> with proper scope for headersscope="col", row headers get scope="row". This clarifies relationships for screen readers.Pass the test and this pattern moves unknown