Table with Scoped Headers Template (Accessibility)

Build truly accessible tables by using the scope attribute to programmatically link data cells to their headers.

This is one of the most important practices for table accessibility, ensuring that screen reader users can navigate and understand complex data.

Screenshot of a simple table. The focus is on the HTML code, not the visual style.

Get Source Code → Preview →

About Scoped Table Headers

For a sighted user, the relationship between a header and a cell is visually obvious. For someone using a screen reader, that relationship must be defined in the code. The scope attribute on a th element does exactly that.

When a screen reader user navigates to a cell (e.g., "$29"), it can announce both the column and row header (e.g., "Price, Premium Plan: $29"). Without scope, it might just read "$29", leaving the user without context. This template provides a clear example of a table with both row and column headers.

Key Features:

Ideal Use Cases:

Dependencies:

None. This is a fundamental HTML attribute.

Code

Here's the full code demonstrating the use of scope on both column and row headers.

View Output