th elementtr element.header, footer, sectioning content, or heading content descendants.colspanrowspanheadersscope
interface HTMLTableHeaderCellElement : HTMLTableCellElement {
attribute DOMString scope;
};
The th element represents
a header cell in a table.
The th element may have a scope content attribute
specified. The scope attribute is an enumerated attribute with five
states, four of which have explicit keywords:
row keyword, which maps to
the row statecol keyword, which maps to
the column staterowgroup keyword, which
maps to the row group stateth element's scope attribute must not be in the row
group state if the element is not anchored in a row group.colgroup keyword, which
maps to the column group stateth element's scope attribute must not be in the column
group state if the element is not anchored in a column group.The scope attribute's missing value default
is the auto state.
The following example shows how the scope attribute's rowgroup value affects which data cells a
header cell applies to.
Here is a markup fragment showing a table:
<table> <thead> <tr> <th> ID <th> Measurement <th> Average <th> Maximum <tbody> <tr> <td> <th scope=rowgroup> Cats <td> <td> <tr> <td> 93 <th scope=row> Legs <td> 3.5 <td> 4 <tr> <td> 10 <th scope=row> Tails <td> 1 <td> 1 <tbody> <tr> <td> <th scope=rowgroup> English speakers <td> <td> <tr> <td> 32 <th scope=row> Legs <td> 2.67 <td> 4 <tr> <td> 35 <th scope=row> Tails <td> 0.33 <td> 1 </table>
This would result in the following table:
| ID | Measurement | Average | Maximum |
|---|---|---|---|
| Cats | |||
| 93 | Legs | 3.5 | 4 |
| 10 | Tails | 1 | 1 |
| English speakers | |||
| 32 | Legs | 2.67 | 4 |
| 35 | Tails | 0.33 | 1 |
The headers in the first row all apply directly down to the rows in their column.
The headers with the explicit scope attributes apply to all the cells in
their row group other than the cells in the first column.
The remaining headers apply just to the cells to the right of them.
