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
HTML Table Generator
Quickly generate HTML table markup with a given number of rows and columns.
Responsive table
An overflow-x:auto wrapper for horizontal table scrolling on narrow screens.
HTML Formatter & Minifier
Format and minify HTML code online. Fully processed in your browser, nothing sent to a server.