The <table> tag

The <table> tag defines a data table. Its structure is built from thead/tbody/tfoot, tr rows, and th/td cells.

Syntax

<table>
  <thead><tr><th>Header</th></tr></thead>
  <tbody><tr><td>Data</td></tr></tbody>
</table>

Attributes

colspan / rowspan (on th/td) Merges cells horizontally or vertically.
scope (on th) "col" or "row" — explicitly states what the header applies to, important for accessibility.

Example

<table>
  <thead>
    <tr><th scope="col">Plan</th><th scope="col">Price</th></tr>
  </thead>
  <tbody>
    <tr><td>Basic</td><td>$0</td></tr>
    <tr><td>Pro</td><td>$9</td></tr>
  </tbody>
</table>

Notes

  • The border, cellpadding, and cellspacing attributes are deprecated — style tables with CSS instead.
  • Tables should hold tabular data, not be used for page layout — that's a deprecated practice.

Accessibility

  • th with scope="col"/"row" helps screen readers correctly announce which row/column a cell belongs to.

Related tools