TutreNews Learn

Semantics and accessibility

Data tables

Goal: Build accessible data tables · 9 min

Tables are for tabular data (timetables, price lists) — never for page layout.

<table>
  <caption>Opening hours</caption>
  <thead><tr><th scope="col">Day</th><th scope="col">Hours</th></tr></thead>
  <tbody><tr><th scope="row">Mon</th><td>9–17</td></tr></tbody>
</table>
  • <tr> row, <td> data cell, <th> header cell
  • scope="col" / scope="row" tells screen readers which cells a header describes
  • <caption> names the table; <thead>, <tbody>, <tfoot> group rows
  • colspan / rowspan merge cells

Worked example: A small price table

  1. caption describes the content.
  2. Header row with scope="col".
  3. Each product name is a row header.
<table>
  <caption>Prices</caption>
  <thead><tr><th scope="col">Item</th><th scope="col">Price</th></tr></thead>
  <tbody>
    <tr><th scope="row">Coffee</th><td>2.50 €</td></tr>
    <tr><th scope="row">Tea</th><td>2.00 €</td></tr>
  </tbody>
</table>