HTML <th> table header cell Tag Reference
The th HTML tag means table header cell, and defines a column or row header cell.
Use it to denote a column or row header, or a column foot cell (e.g. a total)
The <th> HTML/xHTML tag
The table header cell can appear within the <thead>, <tbody> or <tfoot> tags. Within <thead> and <tfoot> it acts as a column header (or footer), and within <tbody> it is a row header.
When to use the <th> tag (semantic use)
Use a table header cell to define a heading for either a column or a row of data. Column header <th> cells, within the <thead> section typically indicate what's inteh column, whereas row header <th> cells typically contain a code or some other piece of data that uniquely identifies the row. In the <tfoot> <th> tags could conceivably repeat the column title, but are more likely to be used to contain a label for summary data cell, as in the example below.
All cells within <thead> will normally be <th> cells (column headers), while only the first cell of each row within <tbody> will usually be a <th> (i.e. a row header) - the rest being <td> data cells.
It's valid in all current versions of HTML and xHTML, and it should always have a closing </th> tag.
Example of <th> tag use
Here's a table using all the tags, including <thead>, <tbody>, <tfoot>, with both <td> table data cells and <th> table header cells, and also a <caption> for good measure.Looks like...
| ID | Product | Unit price | Units ordered | Total |
|---|---|---|---|---|
| Total price | £10.85 | |||
| 1 | Coffee | £1.50 | 3 | £4.50 |
| 2 | Turnips | £0.90/kg | 4 | £3.60 |
| 3 | Rat's tails | £0.25 / 6 | 11 | £2.75 |
(Note, we've added styles to this table.)




<thead>
<th>Product</th>
<th>Unit price</th>
<th>Units ordered</th>
<th>Total</th>
<tfoot>
<td>£10.85 </td>
<tbody>
<td>Coffee</td>
<td>£1.50</td>
<td>3</td>
<td>£4.50</td>
<tr>
<td>Turnips</td>
<td>£0.90/kg</td>
<td>4</td>
<td>£3.60</td>
<tr>
<td>Rat's tails</td>
<td>£0.25 / 6</td>
<td>11</td>
<td>£2.75</td>