Skip to main content
Drupal is a registered trademark of Dries Buytaert
Release: OpenID Connect / OAuth client 3.0.0-alpha9 New alpha version released for module openid_connect (3.0.0-alpha9). Usage Milestone: Google Analytics Module google_analytics crossed 1,000 active installs. Release: Timelinr 1.0.1 Minor update available for module timelinr (1.0.1). Release: GraphQL Compose Codegen 1.1.2 Minor update available for module graphql_compose_codegen (1.1.2). Release: Mapy.com 1.1.3 Minor update available for module mapycom (1.1.3). Release: Ckeditor5 entity browser 3.0.3 Minor update available for module ckeditor5_entity_browser (3.0.3). Release: Ckeditor5 entity browser 3.0.1 Minor update available for module ckeditor5_entity_browser (3.0.1). Release: Ckeditor5 entity browser 3.0.2 Minor update available for module ckeditor5_entity_browser (3.0.2). Release: Teamleader Integration 4.0.2 Minor update available for module teamleader (4.0.2). Module Revived: Entityqueue Buttons 1.1.2 Module entityqueue_buttons updated after 8 months of inactivity (1.1.2).

Table Header Scope Attribute

1,768 sites Security covered Drupal 11 · not 10
View on drupal.org

This module automatically adds the `scope` attribute to table header cells (`<th>`) for improved accessibility. It also converts empty header cells into data cells.

In a table, the scope attribute indicates the direction and range of data cells covered by <th> elements. This module provides functionality to automatically set the scope attribute for these table header cells.

Features

The Table Header Scope Attribute module provides text format filters that process <table> elements to improve accessibility:

  1. Set scope attribute for table headers: Automatically sets the correct scope attribute on <th> elements based on their position in the table.
  2. Transform empty table header to table data: Converts empty <th> elements into <td> elements, as empty headers provide no semantic value.

For example, the following table:

<table>
  <thead>
    <tr>
      <th></th>
      <th>Column header 1</th>
      <th>Column header 2</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <th>Row header 1</th>
      <td>Value A</td>
      <td>Value B</td>
    </tr>
    <tr>
      <th>Row header 2</th>
      <td>Value C</td>
      <td>Value D</td>
    </tr>
  </tbody>
</table>

Will be transformed into:

<table>
  <thead>
    <tr>
      <td></td>
      <th scope="col">Column header 1</th>
      <th scope="col">Column header 2</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <th scope="row">Row header 1</th>
      <td>Value A</td>
      <td>Value B</td>
    </tr>
    <tr>
      <th scope="row">Row header 2</th>
      <td>Value C</td>
      <td>Value D</td>
    </tr>
  </tbody>
</table>

Post-Installation

After installing this module, you can enable its functionality:

  1. Go to Administration » Configuration » Content authoring » Text formats and editors
  2. Edit a text format, for example, "Basic HTML"
  3. Enable both filters:
    • "Set scope attribute for table headers"
    • "Transform empty table header to table data"
  4. Ensure the filters are ordered correctly:
    • Set scope attribute for table headers" must come before "Transform empty table header to table data"
    • Both filters should be below the "Limit allowed HTML tags and correct faulty HTML" filter

Assuming the filters are enabled for a text format that can be used on, e.g., a basic page (node). Create or edit a basic page, then add a table. Indicate the <th> elements in the <table> and save the node. When viewing the (source of the) basic page, the scope attributes are correctly set to the <th> tags.

Depends on

Dependencies of the latest stable release

  • filter Drupal core

Required by

Tracked projects that depend on this one

No tracked projects depend on this one yet.

Activity

Tracked releases
4
Tracked since
Sep 2025
Latest release
9 months ago
Releases (12 mo)
4 ▲ from 0
Maintenance
Slowing

Release Timeline

Releases

Version Type Core Release date
2.0.1 Stable 11 Nov 6, 2025
2.0.0 Stable 11 Sep 11, 2025
2.x-dev Dev 11 Sep 10, 2025
1.0.1 Stable 10–11 Sep 10, 2025