Data Table


A data table is an HTML element that organizes information in rows and columns, where each cell maintains a logical relationship with its headers. Unlike a layout table (used to arrange elements visually), a data table requires semantic markup (tags <th>, scope attribute, <caption> element) so that screen readers convey the context of each value.


A screen reader navigates a table cell by cell, row by row. When it encounters "120 €", it cannot look up the column to understand what this amount represents. It needs the HTML code to tell it: "this cell belongs to column T1 and row North". This is the entire difference between a data table and a grid of silent cells.

#Data or layout: the distinction that changes everything

The RGAA devotes its topic 5 to tables and distinguishes two categories.

A data table contains information structured in two dimensions (columns and rows) where the relationships between cells have meaning. A pricing table, a schedule: these are data tables.

A layout table uses <table> only to arrange elements on the page. No logical relationship between rows and columns. The W3C/WAI recommends assigning it role="presentation" so that assistive technologies ignore it.

Confusing the two is the most common error. A layout table with <th> forces the screen reader to announce fictitious headers. A data table without <th> deprives the user of any context.

#Minimum markup

An accessible data table rests on three elements:

<table>
  <caption>Quarterly sales by region</caption>
  <thead>
    <tr>
      <th scope="col">Region</th>
      <th scope="col">Q1</th>
      <th scope="col">Q2</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <th scope="row">North</th>
      <td>120 €</td>
      <td>145 €</td>
    </tr>
  </tbody>
</table>

<caption> identifies the table. <th> declares headers. scope specifies the direction (column or row). Without these three elements, the screen reader conveys orphaned values.

#The trap of the "visually correct" table

Many developers put their headers in <td> elements styled in bold. The visual rendering is identical. For a screen reader, these cells remain ordinary data cells. No association is created with the values below. As MDN clearly documents: it is HTML semantics, not CSS styling, that determines how assistive technologies behave.

#In summary

A data table has headers (<th> with scope), a title (<caption>), and no role="presentation". If your table doesn't need headers to be understood, it's probably a layout table, and it doesn't need to be a <table>.

Share this article

Learn more