Tables organise data in rows and columns, making it easier for readers to compare information. In HTML a table is built from a set of specific elements that define the table structure.
<table> – container for the whole table.<thead> – groups the header rows.<tbody> – groups the body rows (the main data).<tr> – defines a table row.<th> – table header cell (bold and centred by default).<td> – table data cell.<table> element where the table should appear in the HTML document.<thead> section for the column headings.<thead>, create a row (<tr>) and add header cells (<th>) for each column.<tbody> section for the data rows.<tr> and fill the cells with <td> elements.<table>
<thead>
<tr>
<th>Product</th>
<th>Price (£)</th>
<th>Stock</th>
</tr>
</thead>
<tbody>
<tr>
<td>Notebook</td>
<td>2.50</td>
<td>120</td>
</tr>
<tr>
<td>Pen</td>
<td>0.80</td>
<td>350</td>
</tr>
<tr>
<td>Eraser</td>
<td>0.30</td>
<td>200</td>
</tr>
</tbody>
</table>
| Product | Price (£) | Stock |
|---|---|---|
| Notebook | 2.50 | 120 |
| Pen | 0.80 | 350 |
| Eraser | 0.30 | 200 |
<thead> – browsers will still display the table, but the header may not be distinguished for accessibility tools.<th> and <td> in the same row – keep header cells only in the header row(s).<table> → <thead> / <tbody> → <tr> → <th> / <td>.Create a table that lists the following subjects, their weekly hours, and the teacher’s name:
Use the structure described above and include a <thead> with appropriate headings.