Skip to main content
Albero Academy

Tables in Depth

Build real data tables — full structure with thead/tbody/tfoot, spanning cells, captions, and the markup that keeps them accessible.

Chapter 10HTML13 min readBeginner friendly
  • #HTML
  • #Tables
  • #Accessibility

Chapter 4 covered a basic table; real reports need more — grouped header/body/footer rows, merged cells, a caption, and accessibility markup so assistive tech can read them. Tables are for tabular data only, never page layout (that's CSS Grid's job).

Full structure

thead / tbody / tfoot
<table>
<caption>Programme comparison</caption>
<thead>
<tr><th>Programme</th><th>Duration</th><th>Fee</th></tr>
</thead>
<tbody>
<tr><td>Data Analytics</td><td>6 months</td><td>₹65,000</td></tr>
<tr><td>Full Stack</td><td>9 months</td><td>₹95,000</td></tr>
</tbody>
<tfoot>
<tr><td colspan="2">Average</td><td>₹80,000</td></tr>
</tfoot>
</table>

Spanning cells

colspan merges cells across columns; rowspan down rows:

merged cells
<tr>
<th rowspan="2">Track</th>
<th colspan="2">2026 Intake</th>
</tr>
<tr>
<th>Jan</th><th>Jul</th>
</tr>

Accessible tables

  • Use <th> for header cells and add scope="col" / scope="row" so screen readers associate data with the right header.
  • Give the table a <caption> — a title read out before the data.
scope
<thead>
<tr><th scope="col">Programme</th><th scope="col">Fee</th></tr>
</thead>
<tbody>
<tr><th scope="row">Data Analytics</th><td>₹65,000</td></tr>
</tbody>

Not for layout

Practice

Build a placement-stats table with a caption, thead/tbody/tfoot, a footer average row using colspan, row headers with scope="row", and column headers with scope="col".

Key takeaways

  1. 01Real tables use caption + thead/tbody/tfoot to group rows meaningfully.
  2. 02colspan merges across columns, rowspan down rows.
  3. 03Use <th> with scope="col"/"row" and a <caption> so screen readers can read the table.
  4. 04Tables are for tabular data only — never for page layout (use CSS Grid/Flexbox).