Last updated

Tables

Definition: A table displays data in rows and columns. It is built from a <table>, with <tr> for each row, <th> for header cells, and <td> for data cells.

Structure

<table>
  <tr><th>Name</th><th>Age</th></tr>
  <tr><td>Sam</td><td>25</td></tr>
</table>

The pieces

  • <tr> — table row
  • <th> — header cell (bold and centred by default)
  • <td> — a normal data cell

Each row holds the cells that appear across one line of the table.

💡 Tip: use tables for real tabular data (like a price list), not for page layout — CSS Flexbox (a later lesson) is the modern way to lay out pages.

Try it Yourself
Output

          
Ad · responsive