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
<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:
<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 addscope="col"/scope="row"so screen readers associate data with the right header. - Give the table a
<caption>— a title read out before the data.
<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
- 01Real tables use caption + thead/tbody/tfoot to group rows meaningfully.
- 02colspan merges across columns, rowspan down rows.
- 03Use <th> with scope="col"/"row" and a <caption> so screen readers can read the table.
- 04Tables are for tabular data only — never for page layout (use CSS Grid/Flexbox).
