HTML scope Attribute

Beginner
5 min read
Updated: Oct 2026
3 examples
Live preview

Definition and Usage

The scope attribute on <th> defines which cells that header relates to: the whole row, column, row group, or column group. Screen readers use it to announce the right context for data cells.

For simple tables, browsers often infer scope — but stating it explicitly is clearer and more reliable. For complex multi-header layouts, also use headers with header ids.

Baseline · Widely available.

Not deprecated on <th>. Enumerated values: row, col, rowgroup, colgroup.

Deprecated on <td>.

Do not put scope on data cells. Use <th> for headers.

HTML Syntax

syntax.html
<th scope=" row|col|rowgroup|colgroup">

In JavaScript: th.scope = "col".

Attribute Values

What each value means:

ValueHeader applies toTry it
colAll cells in that columnTry it
rowAll cells in that rowTry it
colgroupAll cells in the column groupTry it
rowgroupAll cells in the row group (thead/tbody/…)Try it

Live Preview

Toggle highlighting for scope="col" vs scope="row" headers. The markup stays the same — CSS only paints the association for study.

Column headers use scope="col". Row headers use scope="row".

table
PlayerScore
Ada95
Lin88

Highlighting: col + row headers

HTML Examples

Short demos. Use Try It Yourself for a live editor.

Example 1 — Column and row headers

The most common pattern: col across the top, row down the side.

HTML
<table>
  <tr>
    <th scope="col">Symbol</th>
    <th scope="col">Code word</th>
  </tr>
  <tr>
    <th scope="row">A</th>
    <td>Alfa</td>
  </tr>
  <tr>
    <th scope="row">B</th>
    <td>Bravo</td>
  </tr>
</table>
Try It Yourself

How It Works

  1. scope="col" marks Symbol / Code word as column titles.
  2. scope="row" marks A / B as row titles.
  3. Data cells stay as <td>.
  4. Assistive tech can announce both contexts for each cell.

Example 2 — scope="colgroup"

Label a group of columns (often with colspan).

HTML
<table>
  <tr>
    <th scope="col" rowspan="2">Product</th>
    <th scope="colgroup" colspan="2">Sales</th>
  </tr>
  <tr>
    <th scope="col">Q1</th>
    <th scope="col">Q2</th>
  </tr>
  <tr>
    <td>Keyboard</td>
    <td>120</td>
    <td>140</td>
  </tr>
</table>
Try It Yourself

How It Works

  1. Sales spans two columns with colspan="2".
  2. scope="colgroup" says it headers that group.
  3. Q1 / Q2 still use scope="col" for each column.
  4. Product uses rowspan + scope="col" across both header rows.

Example 3 — scope="rowgroup"

Header for an entire body section (less common; useful with grouped rows).

HTML
<table>
  <thead>
    <tr>
      <th scope="col">Item</th>
      <th scope="col">Qty</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <th scope="rowgroup" rowspan="2">Fruit</th>
      <td>4</td>
    </tr>
    <tr>
      <td>6</td>
    </tr>
  </tbody>
</table>
Try It Yourself

How It Works

  1. rowgroup marks a header for a block of rows.
  2. rowspan="2" visually covers both fruit rows.
  3. Second body row omits a second header cell (already spanned).
  4. Prefer row/col for simple tables; use groups when structure needs them.

Edge Cases & Pitfalls

Most mistakes are using td as a header or skipping headers on complex grids.

element

Only on <th>

scope on <td> is deprecated.

complex

Multi-level headers may need headers

Link cells to th ids when scope alone is ambiguous.

values

Invalid values are ignored

Stick to row, col, rowgroup, colgroup.

a11y

Inference is not always enough

Explicit scope improves reliability across assistive tech.

Browser Support

scope is an HTML attribute on <th> for table header associations. It is not a Node.js, Deno, or Bun API.

✓ Baseline · Widely available

scope

Supported everywhere modern tables work. Prefer explicit scope on th for accessibility.

98% Global support (approx.)
Google Chrome Yes
Full support
Mozilla Firefox Yes
Full support
Apple Safari Yes
Full support
Microsoft Edge Yes
Full support
Opera Yes
Full support
Samsung Internet Yes
Full support
Internet Explorer Yes
Supported
scope Widely supported

Bottom line: Safe to use on th. Add headers for complex multi-header tables.

Key Takeaways

  • Role: say which cells a <th> headers.
  • Common: col + row for simple grids.
  • Groups: colgroup / rowgroup when structure needs them.
  • Not on td — use headers for complex links.

One line: scope on <th> tells which row/column/group the header labels.

Frequently Asked Questions

On a th element, scope tells which cells that header labels: the whole row, column, row group, or column group. Assistive technologies use it to announce context.
Use scope on th only. Putting scope on td is deprecated — use th for headers instead.
row, col, rowgroup, and colgroup. Invalid or missing values let the browser infer associations, which can be wrong for complex tables.
For simple tables, scope is enough. Use the headers attribute (ids of th cells) when relationships are multi-level or ambiguous.
No. It is an accessibility association. You can still style th[scope="col"] with CSS if you want visual cues.
No on th — it is a Baseline widely available attribute. It is deprecated on td.

Next: scrolling

Learn the obsolete iframe scrolling attribute (and CSS overflow instead).

scrolling tutorial →

About the author

Mari Selvan M P
Mari Selvan M P 🔗

Developer, cloud engineer, and technical writer

  • Experience 12 years building web and cloud systems
  • Focus Full Stack Development, AWS, and Developer Education

I write practical tutorials so students and working developers can learn by doing—from databases and APIs to deployment on AWS.

8 people found this page helpful