Tables

HTML <th> element

Represents a header cell. scope can identify its associated row or column; complex tables may need explicit headers relationships. A th describes a row, column or group of cells. Use scope for straightforward associations, or IDs and headers for complex tables. Styling alone does not create header semantics. It accepts global HTML attributes; individual global features may be inapplicable or restricted.

Formal Syntax & Structure

html syntaxhtml
<th scope="col">Heading</th>

Parameters & Attributes

NameTypeDescription
colspanpositive integerMakes a table cell occupy multiple columns. Default is 1; the conforming range is 1 to 1000. Maintain a coherent table grid.
rowspannon-negative integerMakes a table cell occupy multiple rows. Default is 1; zero extends the cell to the remaining rows in its row group. Avoid overlaps in the resulting grid.
headersspace-separated header IDsAssociates a table cell with th elements in the same table using explicit IDs. Useful for complex header relationships that cannot be expressed clearly using scope alone.
scopeenumerated: row, col, rowgroup, colgroupSpecifies the table cells for which a th acts as a header. Missing scope uses automatic association; use explicit relationships for complex tables.
abbrtextShort alternative for a table header when a compact label is useful, for example in assistive technology.

Return Value

HTMLTableCellElement

Content model: Flow content excluding headings, sectioning content, header and footer.

Working Example

Example Snippethtml
<!doctype html><html lang="en">  <head>    <meta charset="utf-8">    <title>HTML example</title>  </head>  <body>    <table>      <tr>        <th scope="col">Item</th>      </tr>      <tr>        <td>Book</td>      </tr>    </table>  </body></html>
HTML Reference