05 / 06

What is the scope attribute in <th>?

Understanding the scope Attribute in <th>

The scope attribute in a <th> element specifies which cells the header is associated with. It improves accessibility by helping screen readers and other assistive technologies correctly identify header-cell relationships.

Values for the scope Attribute
  1. 1

    col: Applies the header to all cells in the column beneath it.

  2. 2

    row: Applies the header to all cells in the row to its right.

  3. 3

    colgroup: Applies the header to all cells in a column group defined by <colgroup>.

  4. 4

    rowgroup: Applies the header to all cells in a row group defined by <thead>, <tbody>, or <tfoot>.

Example Usage

In short: Use the scope attribute on <th> elements to define whether the header applies to a row, column, or a group. This ensures tables are more accessible and easier to interpret.

Difficulty: 5/10
Topics: Accessibility (a11y), Semantic HTML, Data Tables

Scenario Questions

0-2 years experience
  1. 1

    We have a simple pricing table with features listed on the left and plans across the top. A screen reader user is complaining that they can't tell which plan a price belongs to as they navigate. How would you modify the table markup to fix this?

  2. 2

    If you have a table where the first column contains row headers and the first row contains column headers, how do you explicitly tell assistive technologies which header applies to which data cell?

2-5 years experience
  1. 1

    We're building a complex financial report table with nested headers—like 'Q1' spanning three columns, and then 'Jan', 'Feb', 'Mar' underneath. How would you use the scope attribute to ensure a screen reader reads the hierarchy correctly, and what are the limitations of scope here compared to headers and id attributes?

  2. 2

    A developer on your team styled a table using divs and CSS Grid to make it responsive, but now screen readers aren't announcing the headers correctly. If we refactor this back to a native table, how does the scope attribute help us maintain accessibility without writing custom ARIA roles?

5-8 years experience
  1. 1

    You are designing a reusable DataTable component for your company's design system that needs to support dynamic columns, row grouping, and strict WCAG 2.1 AA compliance. How would you architect the component's API so that developers automatically generate the correct scope or headers attributes without having to manually write complex HTML?

  2. 2

    We have a legacy dashboard with massive, multi-dimensional data tables that are causing performance lag on screen readers. How do you evaluate when to use simple scope attributes versus complex id/headers relationships, and how does this impact the accessibility tree's rendering performance?

8+ years experience
  1. 1

    Our enterprise platform has hundreds of legacy, non-accessible data tables generated by various third-party libraries and legacy codebases. How would you design a strategy to audit, prioritize, and systematically remediate these tables for WCAG compliance, and what automated linting or testing rules would you introduce to prevent developers from shipping tables without proper header associations?

  2. 2

    When defining our company's global frontend engineering standards, there's a debate between enforcing strict semantic HTML (like scope on th) versus using ARIA grid roles on custom div-based components for better CSS styling flexibility. How do you lead this architectural decision, balancing accessibility, developer velocity, and design consistency?

Follow-up Questions

  • What is the difference between using the scope attribute versus the headers and id attributes?
  • How do screen readers behave if you omit the scope attribute on a simple, single-header table?
  • Can you use the scope attribute on a td element, or is it strictly valid on th?