When to use Tables?
Wait! Tables should only be used for Data (like a schedule, a price list, or a set of scores). In the old days, developers used tables for page layout, but that is a major "Don't." Today, we use Flexbox or Grid for layout.
html
The Table Hierarchy
<table>: The main wrapper.<thead>: The header section (optional but recommended).<tbody>: The body section where the main data lives.<tr>: Table Row.<th>: Table Header (Bold and centered by default).<td>: Table Data (A single cell).
Merging Cells
colspan: Merges columns horizontally.rowspan: Merges rows vertically.
html
Summary
| Term | Description |
|---|---|
| tr | Table Row |
| th | Table Header (Title of the column) |
| td | Table Data (The actual value) |
| border | The line around the cells (Usually set in CSS) |
| caption | A title for the whole table |
| Best For | Schedules, spreadsheets, and statistical data |
| Logic | "Columnar data presentation" |
| Safety | Keep tables simple to ensure they work on mobile screens |
| Modern | Use CSS display: block to stack tables on small screens |
| Standard | Use <thead> and <tbody> for better accessibility |
| Identity | The "Spreadsheet" view of the web |