---
name: trace-data-table-headers
description: "Check the id and headers attributes in a complex HTML data table so every value is announced with the right row, column and group headers. Use when a table has multi-level or repeated headers and screen-reader users hear the wrong quarter, unit or region for a cell."
license: CC-BY-4.0
metadata:
  author: Raq.com
  version: "2026-11-22"
  homepage: https://skills.raq.com/skills/trace-data-table-headers
---

# Trace the headers of a complex data table

Check explicit header associations in multi-level tables so a value keeps its row, column and group meanings when read out of visual context.

## When to use this skill

- A table has column or row headers that repeat or change part-way through, or three or more headers per data cell, and uses headers and id attributes.
- A screen-reader user reports that a figure is read out with the wrong heading.
- A developer wants a cell-by-cell check of headers attributes before release.

## When not to use it

- Simple tables with one row of column headers and one column of row headers. Those should use th with scope (W3C technique H63) and need a simpler check.
- Layout tables used only for positioning. They should have no header markup; the fix is to remove table semantics or use CSS for layout.
- Deciding how to restructure a complex table. W3C suggests splitting complex tables into simpler ones where possible, but that is a content decision for the author.

## What you need

- Table cells with IDs, their th/td roles and the exact headers tokens from each data cell.
- The intended header IDs for each data cell based on the table’s real row and column groups.

## Ask before you start

If any of these are missing or unclear, ask before doing the work.

- Can you supply the table markup, or a list of every th id and every data cell's headers attribute? The check works on exact tokens.
- Which headers should each data cell be read with, including group headers such as region or year? Without the intended associations, only broken references can be found.
- Are any ids reused elsewhere on the page, for example by a second copy of the table? HTML ids must be unique in the document.

## Method

1. Confirm this is a data table that needs explicit associations: headers that change part-way down or across, or three or more headers per cell. For a simple grid, recommend th with scope instead and stop.
2. Index every id the headers attributes refer to. Note duplicate ids in the document, and which ids belong to th elements in this same table. HTML requires each headers token to be the id of a th in the same table.
3. For each data cell, split the headers attribute on spaces and resolve each token. A token is unresolved if no element has that id, if the id is duplicated, or if it points to a td or to an element outside the table.
4. Compare the uniquely resolved headers with the headers the cell actually needs. List missing ones in the intended order, then extra ones that resolve but do not belong, such as the wrong quarter, unit or region.
5. Read each corrected cell in isolation, as a screen reader would announce it: the value with its group, row and column headers. It should make sense without seeing the grid. A caption names the table but does not give a cell its unit or period.
6. Give the corrected headers value for each cell with a problem, and note where splitting the table would remove the need for headers attributes altogether.

## Checks before you deliver

- A token that names a data cell or an ID outside the table is unresolved even when that ID exists elsewhere on the page.
- Checking only for the presence of a headers attribute misses the wrong-quarter or wrong-unit association.
- With a duplicated id, browsers use the first element in the document with that id, which may not be the header intended. Treat every duplicate as unresolved until the ids are made unique.
- A headers attribute replaces the browser's automatic header assignment for that cell, so a partial list drops headers that scope would otherwise have supplied.
- Changing a headers value without rechecking the ids it names can introduce a new broken reference. Resolve the tokens again after every fix.

## How to present the result

Start with how many data cells are correct and how many have missing, extra or unresolved headers. Then give a table with each problem cell, its current headers value, what is missing, extra or unresolved, and the corrected headers value ready to paste. End with any duplicate or misplaced ids to fix first and a note on whether the table should be split.

## Worked example

**Request:** Check the explicit associations. All listed th IDs are unique.

**Supplied material:**

```text
th IDs: north, q1, q2, units
cell N1 intended north q1 units; headers="north q2 units"
cell N2 intended north q2 units; headers="north q2 pieces"
```

**Answer:** Set N1’s headers to north q1 units and N2’s to north q2 units. N1 currently announces the wrong quarter. N2 names a nonexistent pieces header. Recheck each cell outside its visual row and column context.

## Structured output for tests

For an ordinary job, answer in the format above and point back to the supplied evidence. Use this structure only for the test cases published with this skill, or when someone asks for structured JSON.

Return cells in data-cell order as {id,missing,extra,unresolved}. missing follows the intended header order, extra lists uniquely resolved but unintended tokens in attribute order, and unresolved lists absent, duplicate-ID or non-th targets in attribute order. Empty arrays represent a clean cell.

## Sources

- [W3C WAI tables with multi-level headers](https://www.w3.org/WAI/tutorials/tables/multi-level/): Says tables whose headers repeat or change part-way through, or that have three or more headers per data cell, should give each th a document-unique id and list those ids in each data cell's headers attribute. It also suggests splitting such tables where possible.
- [W3C technique H43: Using id and headers attributes](https://www.w3.org/WAI/WCAG22/Techniques/html/H43): A sufficient technique for WCAG 2.2 success criterion 1.3.1. Its test checks that each id listed in a data cell's headers attribute matches the id of a cell used as a header, and that cells with several headers list all of them.
- [HTML Standard: the headers attribute](https://html.spec.whatwg.org/multipage/tables.html#attr-tdth-headers): Requires headers tokens to be unique ids of th elements in the same table. Its header assignment algorithm uses the headers list instead of automatic scanning when the attribute is present, and takes the first element in the document with each id, which is why duplicates and partial lists cause wrong announcements.

Test cases and an answer checker for this skill: https://skills.raq.com/skills/trace-data-table-headers
