{"skills":[{"name":"Trace the headers of a complex data table","description":"Check explicit header associations in multi-level tables so a value keeps its row, column and group meanings when read out of visual context.","content":"# Trace the headers of a complex data table\n\nCheck explicit header associations in multi-level tables so a value keeps its row, column and group meanings when read out of visual context.\n\n## When to use this skill\n\n- 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.\n- A screen-reader user reports that a figure is read out with the wrong heading.\n- A developer wants a cell-by-cell check of headers attributes before release.\n\n## When not to use it\n\n- 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.\n- Layout tables used only for positioning. They should have no header markup; the fix is to remove table semantics or use CSS for layout.\n- 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.\n\n## What you need\n\n- Table cells with IDs, their th\/td roles and the exact headers tokens from each data cell.\n- The intended header IDs for each data cell based on the table\u2019s real row and column groups.\n\n## Ask before you start\n\nIf any of these are missing or unclear, ask before doing the work.\n\n- 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.\n- 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.\n- 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.\n\n## Method\n\n1. 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.\n2. 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.\n3. 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.\n4. 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.\n5. 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.\n6. 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.\n\n## Checks before you deliver\n\n- A token that names a data cell or an ID outside the table is unresolved even when that ID exists elsewhere on the page.\n- Checking only for the presence of a headers attribute misses the wrong-quarter or wrong-unit association.\n- 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.\n- 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.\n- Changing a headers value without rechecking the ids it names can introduce a new broken reference. Resolve the tokens again after every fix.\n\n## How to present the result\n\nStart 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.\n\n## Worked example\n\n**Request:** Check the explicit associations. All listed th IDs are unique.\n\n**Supplied material:**\n\n```text\nth IDs: north, q1, q2, units\ncell N1 intended north q1 units; headers=\"north q2 units\"\ncell N2 intended north q2 units; headers=\"north q2 pieces\"\n```\n\n**Answer:** Set N1\u2019s headers to north q1 units and N2\u2019s 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.\n\n## Structured output for tests\n\nFor 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.\n\nReturn 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.\n\n## Sources\n\n- [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.\n- [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.\n- [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.\n\nTest cases and an answer checker for this skill: https:\/\/skills.raq.com\/skills\/trace-data-table-headers\n","scope":"contextual","trigger_keywords":["Trace the headers of a complex data table","trace-data-table-headers","trace data table headers","Will a screen reader announce the right headers for each cell in this table?","Will a screen reader announce the right headers for each cell in this table","table header associations","headers for this cell","screen reader table headers"],"is_private":true,"is_active":true,"scripts":[{"name":"trace-data-table-headers-check","description":"Compare a saved JSON answer with a published test. Pass tests\/case-1\/expected.json (or another case) and the path to your answer.","language":"python","filename":"trace-data-table-headers-check.py","content":"from pathlib import Path\nimport runpy\n\nrunpy.run_path(str(Path(__file__).parent \/ 'tests' \/ 'check.py'), run_name='__main__')\n","supporting_files":[{"path":"SKILL.md","content":"---\nname: trace-data-table-headers\ndescription: \"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.\"\nlicense: CC-BY-4.0\nmetadata:\n  author: Raq.com\n  version: \"2026-11-22\"\n  homepage: https:\/\/skills.raq.com\/skills\/trace-data-table-headers\n---\n\n# Trace the headers of a complex data table\n\nCheck explicit header associations in multi-level tables so a value keeps its row, column and group meanings when read out of visual context.\n\n## When to use this skill\n\n- 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.\n- A screen-reader user reports that a figure is read out with the wrong heading.\n- A developer wants a cell-by-cell check of headers attributes before release.\n\n## When not to use it\n\n- 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.\n- Layout tables used only for positioning. They should have no header markup; the fix is to remove table semantics or use CSS for layout.\n- 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.\n\n## What you need\n\n- Table cells with IDs, their th\/td roles and the exact headers tokens from each data cell.\n- The intended header IDs for each data cell based on the table\u2019s real row and column groups.\n\n## Ask before you start\n\nIf any of these are missing or unclear, ask before doing the work.\n\n- 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.\n- 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.\n- 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.\n\n## Method\n\n1. 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.\n2. 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.\n3. 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.\n4. 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.\n5. 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.\n6. 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.\n\n## Checks before you deliver\n\n- A token that names a data cell or an ID outside the table is unresolved even when that ID exists elsewhere on the page.\n- Checking only for the presence of a headers attribute misses the wrong-quarter or wrong-unit association.\n- 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.\n- 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.\n- Changing a headers value without rechecking the ids it names can introduce a new broken reference. Resolve the tokens again after every fix.\n\n## How to present the result\n\nStart 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.\n\n## Worked example\n\n**Request:** Check the explicit associations. All listed th IDs are unique.\n\n**Supplied material:**\n\n```text\nth IDs: north, q1, q2, units\ncell N1 intended north q1 units; headers=\"north q2 units\"\ncell N2 intended north q2 units; headers=\"north q2 pieces\"\n```\n\n**Answer:** Set N1\u2019s headers to north q1 units and N2\u2019s 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.\n\n## Structured output for tests\n\nFor 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.\n\nReturn 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.\n\n## Sources\n\n- [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.\n- [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.\n- [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.\n\nTest cases and an answer checker for this skill: https:\/\/skills.raq.com\/skills\/trace-data-table-headers\n"},{"path":"LICENSE.txt","content":"Original Raq.com instructions and synthetic examples: CC BY 4.0.\nhttps:\/\/creativecommons.org\/licenses\/by\/4.0\/\nAttribution: Raq.com, https:\/\/skills.raq.com\/skills\/trace-data-table-headers\nReferenced third-party materials retain their own terms.\n"},{"path":"examples\/worked-example.md","content":"# Quarterly output table\n\nCheck the explicit associations. All listed th IDs are unique.\n\n## Supplied material\n\nth IDs: north, q1, q2, units\ncell N1 intended north q1 units; headers=\"north q2 units\"\ncell N2 intended north q2 units; headers=\"north q2 pieces\"\n\n## Worked answer\n\nSet N1\u2019s headers to north q1 units and N2\u2019s 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.\n\n## Reasoning\n\nThe first cell refers to an existing but incorrect quarter. The second refers to an absent unit label.\n"},{"path":"tests\/check.py","content":"\"\"\"Check a saved agent answer locally with Python 3 (standard library only).\"\"\"\nimport json\nimport math\nimport sys\nfrom pathlib import Path\n\n\ndef compare(expected, actual, path=\"$\", accepted=None):\n    if isinstance(expected, bool) or isinstance(actual, bool):\n        if expected is not actual:\n            yield path\n    elif isinstance(expected, (int, float)) and isinstance(actual, (int, float)):\n        if not math.isclose(expected, actual, rel_tol=0, abs_tol=1e-8):\n            yield path\n    elif isinstance(expected, dict) and isinstance(actual, dict):\n        for key in sorted(set(expected) | set(actual)):\n            if key not in expected or key not in actual:\n                yield f\"{path}.{key}\"\n            elif not any(\n                not list(compare(option, actual[key]))\n                for option in (accepted or {}).get(key, [])\n            ):\n                yield from compare(expected[key], actual[key], f\"{path}.{key}\")\n    elif isinstance(expected, list) and isinstance(actual, list):\n        if len(expected) != len(actual):\n            yield f\"{path} (length)\"\n        for i, (left, right) in enumerate(zip(expected, actual)):\n            yield from compare(left, right, f\"{path}[{i}]\")\n    elif type(expected) != type(actual) or expected != actual:\n        yield path\n\n\ndef main():\n    if len(sys.argv) != 3:\n        raise SystemExit(\"Usage: python3 check.py expected.json answer.json\")\n    try:\n        expected, actual = [json.loads(Path(p).read_text(encoding=\"utf-8\")) for p in sys.argv[1:]]\n        alternatives = Path(sys.argv[1]).with_name(\"accepted.json\")\n        accepted = json.loads(alternatives.read_text(encoding=\"utf-8\")) if alternatives.is_file() else {}\n    except (ValueError, OSError) as error:\n        raise SystemExit(str(error))\n    differences = list(compare(expected, actual, accepted=accepted))\n    if differences:\n        raise SystemExit(\"Different fields: \" + \", \".join(differences))\n    print(\"Pass\")\n\n\nif __name__ == \"__main__\":\n    main()\n"},{"path":"tests\/README.md","content":"Give your agent SKILL.md and one request.txt in a fresh session. Keep the expected answer aside. Save the reply as answer.json, then run this from the tests folder:\n\n    python3 check.py case-1\/expected.json answer.json\n\nEach case also has an explanation. Where accepted.json exists, the checker accepts the alternatives listed there.\n"},{"path":"tests\/case-1\/request.txt","content":"Check the explicit associations. All listed th IDs are unique.\nReturn only the JSON specified in SKILL.md for this test.\n\nth IDs: north, q1, q2, units\ncell N1 intended north q1 units; headers=\"north q2 units\"\ncell N2 intended north q2 units; headers=\"north q2 pieces\"\n"},{"path":"tests\/case-1\/expected.json","content":"{\n    \"cells\": [\n        {\n            \"id\": \"N1\",\n            \"missing\": [\n                \"q1\"\n            ],\n            \"extra\": [\n                \"q2\"\n            ],\n            \"unresolved\": []\n        },\n        {\n            \"id\": \"N2\",\n            \"missing\": [\n                \"units\"\n            ],\n            \"extra\": [],\n            \"unresolved\": [\n                \"pieces\"\n            ]\n        }\n    ]\n}\n"},{"path":"tests\/case-1\/explanation.txt","content":"The first cell refers to an existing but incorrect quarter. The second refers to an absent unit label.\n"},{"path":"tests\/case-2\/request.txt","content":"Check the explicit table associations.\nReturn only the JSON specified in SKILL.md for this test.\n\nth IDs: region, year, year, total\ntd ID: x\ncell B1 intended region year; headers=\"region year x\"\ncell B2 intended region total; headers=\"region total\"\n"},{"path":"tests\/case-2\/expected.json","content":"{\n    \"cells\": [\n        {\n            \"id\": \"B1\",\n            \"missing\": [\n                \"year\"\n            ],\n            \"extra\": [],\n            \"unresolved\": [\n                \"year\",\n                \"x\"\n            ]\n        },\n        {\n            \"id\": \"B2\",\n            \"missing\": [],\n            \"extra\": [],\n            \"unresolved\": []\n        }\n    ]\n}\n"},{"path":"tests\/case-2\/explanation.txt","content":"The duplicate year cannot identify a unique header. The data-cell ID cannot name a header.\n"}],"is_active":true,"is_approved":false}]}]}