Knowledge baseExam Center
ENEnglish
Choose language13

CKTIS / HTML

headers — explicitly associate a cell with headers

The headers attribute on td and th cells identifies header cells by their id values. It explicitly describes table relationships, particularly when the table structure is complex.

Version: WHATWG HTML Living Standard; index snapshot date recorded separately

Syntax

td: headers="header-id-1 header-id-2"; th: headers="header-id-1 header-id-2"

headers assigns table headers to a td or th cell. Its value is an unordered set of unique IDs separated by ASCII whitespace. Each must identify a th element in the same table; do not use commas or a # prefix.

A header must not target itself, including indirectly through other headers. headers lists the headers of a particular cell; in contrast, scope on th defines the area to which a header applies.

The presence of headers replaces automatic header assignment for that cell rather than supplementing it. Consequently, headers="" assigns no headers. These relationships can provide context in nonvisual presentation; do not assume a particular announcement.

In the example, 42 explicitly has the headers ada and score. The expected output represents the table text, not exact spacing or screen-reader announcements.

Examples

<!doctype html>
<html lang="en">
<meta charset="utf-8">
<title>Table headers</title>
<table>
  <caption>Scores</caption>
  <tr><th>Student</th><th id="score">Score</th></tr>
  <tr><th id="ada">Ada</th><td headers="ada score">42</td></tr>
</table>
</html>

Result

Scores
Student | Score
Ada     | 42

The displayed code and declared result were verified in an isolated environment using the method recorded in the verification evidence for this exact version.

Sources