HTML <th> Element

The <th> element defines a header cell within an HTML table. Header cells identify or describe the data in one or more rows or columns and help users understand how the information in the table is organized.

Syntax

<tr>
  <th>Product</th>
  <th>Price</th>
</tr>

Attributes

The <th> element supports the global HTML attributes and the following element-specific attributes:

Attribute Description
abbr Provides a short alternative label for the header cell that can be used when referring to the cell in other contexts.
colspan Specifies how many columns the header cell should span. Its value is a positive integer.
headers Contains one or more space-separated id values identifying other <th> elements that provide header information for the cell.
rowspan Specifies how many rows the header cell should span. A value of 0 causes the cell to extend through the remaining rows in its table row group.
scope Indicates which cells the header applies to. Values include row, col, rowgroup, and colgroup.

Example

This example uses <th> elements with the scope attribute to identify the column headings for a simple product table.

Play in Editor

Usage Notes

A <th> element is placed inside a <tr> element and represents a header cell rather than a regular data cell. Use <td> for cells that contain ordinary table data.

Header cells can identify columns, rows, or groups of rows and columns. The scope attribute can explicitly describe this relationship and is especially useful when a table contains both row and column headings.

The colspan and rowspan attributes allow a header cell to extend across multiple columns or rows when the structure of the table requires grouped headings.

Accessibility

Use <th> elements for cells that function as headings rather than making ordinary <td> cells look like headings with CSS. Correctly marked header cells help assistive technologies associate table data with the appropriate row or column headings. For complex tables, use scope or explicit header relationships when necessary to make these associations clear.

Browser Support

Baseline: Widely available indicates a feature has been supported by core browsers for at least 30 months. At this stage, the feature is considered stable and safe for most websites to use without needing to worry about compatibility issues or fallbacks, as it is supported by the vast majority of users' devices and browser versions.

For detailed browser compatibility information, see Can I Use: HTML <th> Element .

The <th> element is used with other table elements, including <table>, <thead>, <tbody>, <tr>, and <td>.

Specifications

The <th> element is defined in the WHATWG HTML Living Standard .