**`<table>`** is the container for genuinely tabular data — data with real rows and columns where each cell's meaning depends on its row and column headers, like a pricing table, a schedule, or a spreadsheet export. It's built from `<tr>` (rows) containing `<th>` (header cells) and `<td>` (data cells), and can be further organized with `<thead>`, `<tbody>`, `<tfoot>`, and `<caption>`. Tables should NOT be used for page layout — that was a common practice in the 1990s/2000s, but CSS (flexbox, grid) is the correct tool for visual layout today.
1Understanding <table>
`<table>` is the container for genuinely tabular data — data with real rows and columns where each cell's meaning depends on its row and column headers, like a pricing table, a schedule, or a spreadsheet export. It's built from <tr> (rows) containing <th> (header cells) and <td> (data cells), and can be further organized with <thead>, <tbody>, <tfoot>, and <caption>. Tables should NOT be used for page layout — that was a common practice in the 1990s/2000s, but CSS (flexbox, grid) is the correct tool for visual layout today.
A quick test for whether content belongs in a <table>: if you removed the visual borders, would the information still clearly relate row-to-column? If yes, it's tabular data. If you're just trying to align unrelated boxes on a page, use CSS Grid or Flexbox instead.
<table>
<caption>Quarterly Sales</caption>
<tr>
<th>Quarter</th>
<th>Revenue</th>
</tr>
<tr>
<td>Q1</td>
<td>$50,000</td>
</tr>
</table>2Practical Example
Here is a real-world application of <table> showing how it is used in production HTML.
| Sidebar | Main content |
3Best Practices
Follow these guidelines when working with <table>:
1. Use <table> only for genuinely tabular data, never for page layout
2. Always include header cells (<th>) so screen readers can announce column/row context per cell
3. Add a <caption> describing what the table represents
Tip: A quick test for whether content belongs in a <table>: if you removed the visual borders, would the information still clearly relate row-to-column? If yes, it's tabular data. If you're just trying to align unrelated boxes on a page, use CSS Grid or Flexbox instead.
<table>
<caption>Quarterly Sales</caption>
<tr>
<th>Quarter</th>
<th>Revenue</th>
</tr>
<tr>
<td>Q1</td>
<td>$50,000</td>
</tr>
</table>