HTML <th scope=""> tag
- closing tag
- required
- void element
- no
- lives inside
- a <tr>
- typically holds
- a short header label
Where it goes
In the first row for column headers, or as the first cell of a row for row headers. <th> and <td> can mix in the same row.
Example
<tr>
<th scope="col">Item</th>
<th scope="col">Price</th>
</tr>
<tr>
<td colspan="2">Total: $12</td>
</tr>Open this example in the editor →
Common mistakes
- Using bold <td> cells for headers. They look the same but say nothing about which values they describe.
- Leaving off scope on a table with both column and row headers. The browser has to guess which way each header applies, and often guesses wrong.
- Setting colspan to a number that does not match the real column count. The row ends up a different width and the grid falls apart.