Reference · Beginner

HTML table elements

Represent comparable data with table, caption, row groups, header cells, data cells, and explicit header relationships.

Editorial preview — publication review is still required.

Author
Editorial team
Reviewer
Publication review pending
Review tier
180-day

Definition

A table represents data with more than one dimension. Captions name the dataset; header and data cells express relationships.

Practical syntax

<table>
  <caption>
    Course availability
  </caption>
  <thead>
    <tr>
      <th scope="col">Course</th>
      <th scope="col">Seats</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <th scope="row">HTML basics</th>
      <td>12</td>
    </tr>
  </tbody>
</table>

Accessibility

Use th and scope for straightforward row and column headers. More complex tables may require id and headers, but simplifying the data often helps every reader.

Common misuse

Do not use tables for page layout. Avoid empty cells used only for spacing. Do not convert a table into disconnected cards unless each card repeats the headers needed to understand every value.