HTML Tables
Tables display data in rows and columns. Perfect for pricing comparisons, schedules, and data grids. They were infamously abused for page layout in the 1990s before CSS existed.
Basic Table
<table> <thead> <tr> <th scope="col">Name</th> <th scope="col">Score</th> </tr> </thead> <tbody> <tr> <td>Shiva</td> <td>95%</td> </tr> </tbody> </table>
| Name | Score |
|---|---|
| Shiva | 95% |
| Rahul | 88% |
Full Table with caption and tfoot
<table> <caption>CIWeb Course Plans</caption> <thead> <!-- column headers --> <tbody> <!-- data rows --> <tfoot> <!-- totals or notes --> </table>
Merging Cells with colspan and rowspan
<tr> <td colspan="2">This spans 2 columns</td> </tr> <tr> <td>Col 1</td> <td>Col 2</td> </tr>
| This spans 2 columns | |
| Col 1 | Col 2 |
Never use tables for page layout. That 1990s practice breaks responsive design, fails accessibility audits, and is a red flag in job interviews. Use CSS Flexbox or Grid instead.
Before CSS, developers used invisible 1x1 pixel GIF images and up to 50 nested tables for layouts. CSS Grid finally made this completely obsolete in 2017.