Learn Programming, Tech & Coding · Free Online Tools

IT Question Answer
Back to HTML
Understanding HTML Tables

Understanding HTML Tables

HTML1,328 viewsBy Admin
htmlunderstandingtables

Advertisement

HTML Tables

Tables display tabular data in rows and columns. Use them for actual data — not for page layout (use CSS for that).

Table Structure

<table>
  <thead>
    <tr><th>Name</th><th>Age</th></tr>
  </thead>
  <tbody>
    <tr><td>Sara</td><td>25</td></tr>
    <tr><td>Ali</td><td>30</td></tr>
  </tbody>
</table>

Key Elements

  • <table> — the container.
  • <tr> — table row.
  • <th> — header cell (bold, centered).
  • <td> — data cell.

Spanning Cells

<td colspan="2">Spans 2 columns</td>
<td rowspan="3">Spans 3 rows</td>

FAQs

Should I use tables for layout?

No — use CSS Grid or Flexbox. Tables are for data only. More in our HTML section.

How do I make tables responsive?

Wrap in a scrollable container or use CSS to stack cells on mobile.

Advertisement