Skip to main content

The <th> Element

As defined in the HTML Living Standard, the <th> element represents a header cell in a table. It is used to label a group of data cells, providing context and structure to the tabular data.

Visual Example:

Device Browser Status
Desktop Chrome Verified
Mobile Safari Pending

(Note: Headers are used for both column titles and row titles.)

<tr> <th scope="col">Column Header</th> <td>Data Cell</td> </tr> View HTML Living Standard: The th element

Accessibility: The scope Attribute

To provide an accessible experience, <th> elements must be programmatically linked to the data they describe.

WCAG Requirement: Info and Relationships

Success Criterion 1.3.1 (Level A): Information, structure, and relationships conveyed through presentation can be programmatically determined.

The scope attribute is the primary mechanism for meeting this criterion in simple tables. It tells assistive technology if the header applies to the rest of the column (scope="col") or the rest of the row (scope="row").

When a screen reader user moves from cell to cell, the browser announces the associated headers. Without scope, the user hears "Chrome, Verified" but has no way of knowing those values belong to the "Browser" and "Status" categories.

Understand SC 1.3.1: Info and Relationships

Technical Attributes

<!-- Using abbr for long headers --> <th scope="col" abbr="Compliance">Accessibility Compliance Level</th>

Best Practices

A11y Tip: Alignment and Scannability

Following SMACSS Module Rules, headers should be visually distinct from data (e.g., using bold text or background colors). However, ensure the text remains left-aligned if the data is left-aligned to help users with low vision or cognitive impairments track the relationship between the header and the content below it.