HTML headers Attribute

Beginner
6 min read
Updated: Oct 2026
3 examples
Live preview

Definition and Usage

The headers attribute on a <td> or <th> lists the id values of header cells that label that cell. The value is a space-separated list of unique ids. Assistive technologies use these links to announce the correct context for each cell.

For simple tables, scope on <th> is often enough. Prefer headers when cells have multiple labels—for example after rowspan / colspan or multi-level headers.

Baseline · Widely available.

Not deprecated and not experimental. Stable across modern browsers since about July 2015. Applies to table cells only.

Accessibility only — no visual change.

headers does not style the table. Ids must be unique, point to <th> cells in the same table, and never reference the cell itself.

HTML Syntax

syntax.html
<td headers=" header_id header_id …">

Each header_id must match the id of a <th> in the same <table>. The same pattern works on <th> for nested headers.

Attribute Values

Unordered set of unique, space-separated tokens:

ValueDescriptionTry it
idOne header cell id, e.g. headers="name"Try it
id1 id2 …Several headers for one cell, e.g. headers="north jan q1"Try it
On <td>Primary use: associate data cells with their labelsTry it
On <th>Sub-headers can reference a parent group headerTry it
Spanned cellA rowspan/colspan cell can list every related header idTry it

Live Preview

Click a data cell to see its headers value and which header cells it references.

Click any number cell. The note below lists the linked header ids.

Sales table
Q1 units by region
RegionJanFeb
North120140
South95110

Click a data cell to inspect its headers attribute.

HTML Examples

Short, copy-ready snippets. Use Try It Yourself for a live editor.

Example 1 — Column Header Ids

Give each column <th> an id, then point each <td> at that id with headers.

HTML
<table>
  <caption>Student scores</caption>
  <thead>
    <tr>
      <th id="name" scope="col">Name</th>
      <th id="score" scope="col">Score</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td headers="name">Alice</td>
      <td headers="score">92</td>
    </tr>
    <tr>
      <td headers="name">Bob</td>
      <td headers="score">87</td>
    </tr>
  </tbody>
</table>
Try It Yourself

How It Works

  1. Mark headers. Each column <th> gets a unique id (name, score).
  2. Link data cells. Each <td> sets headers to the matching column id.
  3. Keep scope too. scope="col" helps simple tables; headers makes the link explicit.
  4. Add a caption. A short <caption> names the table for everyone.

Example 2 — Row and Column Headers Together

When a cell belongs to both a row header and a column group, list every related id.

HTML
<table>
  <tr>
    <th id="region" rowspan="2">Region</th>
    <th id="q1" colspan="2">Q1 Sales</th>
  </tr>
  <tr>
    <th id="jan" headers="q1">Jan</th>
    <th id="feb" headers="q1">Feb</th>
  </tr>
  <tr>
    <th id="north" scope="row">North</th>
    <td headers="north jan q1">120</td>
    <td headers="north feb q1">140</td>
  </tr>
  <tr>
    <th id="south" scope="row">South</th>
    <td headers="south jan q1">95</td>
    <td headers="south feb q1">110</td>
  </tr>
</table>
Try It Yourself

How It Works

  1. Ids on every label. Region, Q1, Jan, Feb, North, and South each get an id.
  2. Sub-headers point up. Jan and Feb use headers="q1" to join the group header.
  3. Data cells list all labels. headers="north jan q1" ties one number to row, month, and group.
  4. Order does not matter. Keep a consistent order in your code for readability.

Example 3 — Spanned Cell, Multiple Row Headers

A cell that spans several rows can reference every row header it covers.

HTML
<table>
  <tr>
    <th id="a" scope="row">A</th>
    <td>Alfa</td>
    <td headers="a b c" rowspan="3">ABC</td>
  </tr>
  <tr>
    <th id="b" scope="row">B</th>
    <td>Bravo</td>
  </tr>
  <tr>
    <th id="c" scope="row">C</th>
    <td>Charlie</td>
  </tr>
</table>
Try It Yourself

How It Works

  1. Row headers need ids. A, B, and C each get an id so they can be referenced.
  2. rowspan covers three rows. The ABC cell visually spans A, B, and C.
  3. headers lists all three. headers="a b c" tells assistive tech which rows that span belongs to.
  4. Prefer descriptive ids. Short letters are fine for demos; real pages should use clear names.

Edge Cases & Pitfalls

Broken associations usually come from wrong ids or overusing headers on simple tables.

ids

Ids must exist in the same table

Every token in headers must match a cell id in that table. Missing or out-of-table ids break the association.

unique

Document-wide unique ids

Duplicate ids make the wrong header match. Prefer prefixed ids when a page has several tables.

scope

Do not overuse on simple tables

For one header row and optional row headers, scope is usually enough. Extra headers markup adds noise and error risk.

self

Never reference the cell itself

A cell must not include its own id in headers. Tokens should only point to other header cells.

deprecated

axis is deprecated

Do not use the old axis attribute. Use id + headers (or scope) for modern tables.

Browser Support

headers is an HTML attribute for table cells in the browser. It is not a Node.js, Deno, or Bun API.

✓ Baseline · Widely available

headers

Widely available since about July 2015. Chrome, Firefox, Safari, Edge, and Opera support it. Screen-reader quality still depends on correct ids and valid table structure.

97% Global support (approx.)
Google Chrome All
Full support
Mozilla Firefox All
Full support
Apple Safari All
Full support
Microsoft Edge All
Full support
Opera All
Full support
Samsung Internet All
Full support
Internet Explorer All
Supported
headers Widely supported

Bottom line: Safe to use wherever you need explicit cell-to-header associations. Validate ids and test with a screen reader on complex tables.

Key Takeaways

  • Role: explicitly link a cell to one or more <th> ids for assistive tech.
  • Format: space-separated unique ids — not commas.
  • When: complex tables with multiple labels; use scope for simple ones.
  • Check: ids unique, same table, no self-reference.

One line: headers names which header cells label a cell — it does not change the look of the table.

Frequently Asked Questions

On a td or th cell, headers lists the id values of th cells that label it. Screen readers use those links to announce the right row and column context.
Only table cells: td and th. Each referenced header cell must be a th with a unique id in the same table.
Use scope on th for simple row or column tables. Use headers when a cell belongs to several headers—merged cells, multi-level headers, or layouts where scope alone is ambiguous.
Space-separated. Example: headers="north jan q1". Commas are incorrect for this attribute.
No. It is an accessibility association only. Layout and styling stay the same.
Use the HTMLTableCellElement.headers property: cell.headers = "id1 id2". It is a space-separated string of header ids.

Next: height

Set intrinsic height on images, iframes, canvas, and video.

height tutorial →

About the author

Mari Selvan M P
Mari Selvan M P 🔗

Developer, cloud engineer, and technical writer

  • Experience 12 years building web and cloud systems
  • Focus Full Stack Development, AWS, and Developer Education

I write practical tutorials so students and working developers can learn by doing—from databases and APIs to deployment on AWS.

8 people found this page helpful