0Pricing
Web Accessibility Academy · Lesson

Complex Tables: headers and id Pairing

Handle spanned and multi-level header tables.

Complex Tables: headers and id Pairing is a free Web Accessibility Academy lesson on CoddyKit — lesson 3 of 4. You can read the complete lesson below for free — then practise it hands-on in the browser with a built-in code editor and a 24/7 AI tutor. It is part of the Web Accessibility Academy learning path, one of 4 lessons in the course, and your progress syncs across the web and the CoddyKit app.

When scope Is Not Enough

Some tables span cells or stack multiple header levels. Simple scope cannot describe a cell governed by two or three headers at once.

Spanned Headers Break Scope

A header that uses colspan to cover several columns confuses the simple model. The browser can no longer guess which cells it owns.

<th colspan="2" scope="colgroup">Q1</th>

The id and headers Pairing

For complex tables, give each th an id and point each td to its headers by id. This wires cells to headers explicitly, no guessing.

<th id="q1">Q1</th>

Listing Multiple Header ids

A data cell can name several headers in its headers attribute, separated by spaces. The reader announces them all in the order you list.

<td headers="ada q1">92</td>

A Worked Example

Give the row header and column header each an id, then reference both from the cell. Now the value is fully described across both axes.

<th id="ada" scope="row">Ada</th>
<td headers="ada q1">92</td>

scope=colgroup and rowgroup

For grouped headers, scope can be colgroup or rowgroup. Use these when one header spans a band of columns or rows above the detail headers.

<th colspan="2" scope="colgroup">2024</th>

Two Header Levels

A year header over month headers needs both levels described. With id and headers each cell can reference the year and the month together.

Keep ids Unique

Every id on the page must be unique. Duplicate header ids silently break the pairing, so a quick validator pass saves real pain later.

Order in headers Matters

List ids in the order you want them read, usually the broadest header first. The screen reader follows your order exactly when it announces.

<td headers="year2024 month-jan ada">92</td>

Simplify Before You Complicate

Before reaching for id and headers, ask if you can split one giant table into smaller simple ones. A simpler structure is almost always more accessible.

Verify in a Screen Reader

The id and headers technique is powerful but easy to mistype. Always confirm a few cells read correctly with a real screen reader, not just by eye.

Quick Check

A data cell is governed by both a row header and a spanned column header.

Recap: Explicit Pairing for Hard Tables

When spans or stacked levels defeat scope, give headers an id and reference them from each cell with headers. Keep ids unique and verify by ear.

Frequently asked questions

Is the “Complex Tables: headers and id Pairing” lesson free?

Yes — the full text of “Complex Tables: headers and id Pairing” is free to read here on the web, and the Web Accessibility Academy course includes 4 lessons in total. To practise it interactively (a built-in code editor and a 24/7 AI tutor) and unlock the rest of the Web Accessibility Academy course, upgrade to CoddyKit PRO.

What will I learn in “Complex Tables: headers and id Pairing”?

Handle spanned and multi-level header tables. You practise Web Accessibility Academy with hands-on code you run directly in the browser, and a 24/7 AI tutor answers your questions as you work through the lesson.

Do I need any experience to start Web Accessibility Academy?

No prior experience is required. Web Accessibility Academy on CoddyKit is structured for beginners through advanced learners; this is — lesson 3 of 4, so you can start here or from the beginning and move at your own pace.

How long does the “Complex Tables: headers and id Pairing” lesson take?

Most CoddyKit lessons take about 5–10 minutes. Each one is bite-sized and interactive, so you make steady progress and pick up exactly where you left off across the web and the app.

Can I write and run code in this Web Accessibility Academy lesson?

Yes. Every Web Accessibility Academy lesson includes a built-in code editor, so you write and run real code right in your browser and get instant AI feedback — no local setup required.

All lessons in this course

  1. th, scope, and the caption Element
  2. Row and Column Headers Done Right
  3. Complex Tables: headers and id Pairing
  4. Layout Tables Are a Trap
← Back to Web Accessibility Academy