What are Tables?
Tables are like spreadsheets (Excel) — they show data in rows and columns.
Basic table structure:
1<table border="1">
2 <caption>Employee Directory</caption>
3 <thead>
4 <tr>
5 <th>Name</th>
6 <th>Position</th>
7 <th>Salary</th>
8 </tr>
9 </thead>
10 <tbody>
11 <tr>
12 <td>John Doe</td>
13 <td>Developer</td>
14 <td>$60,000</td>
15 </tr>
16 <tr>
17 <td>Jane Smith</td>
18 <td>Manager</td>
19 <td>$75,000</td>
20 </tr>
21 </tbody>
22</table>Table parts explained:
Tag | Full Form | Purpose |
|---|---|---|
| Table | Wraps the whole table |
| Caption | Title of the table |
| Table Head | Header section (usually column names) |
| Table Header | A header cell (bold by default) |
| Table Body | Main content section |
| Table Row | A single row |
| Table Data | A normal cell |
When to use tables:
Showing price lists
Displaying comparison charts
Showing schedules/timetables
Financial data
NOT for layout (use CSS Grid/Flexbox instead)
