Drupal is a registered trademark of Dries Buytaert
cms 2.1.3 Update released for Drupal core (2.1.3)! drupal 10.5.11 Update released for Drupal core (10.5.11)! drupal 11.3.11 Update released for Drupal core (11.3.11)! drupal 11.2.13 Update released for Drupal core (11.2.13)! drupal 10.6.10 Update released for Drupal core (10.6.10)! cms 2.1.2 Update released for Drupal core (2.1.2)! drupal 11.1.10 Update released for Drupal core (11.1.10)! drupal 10.5.10 Update released for Drupal core (10.5.10)! drupal 10.4.10 Update released for Drupal core (10.4.10)! drupal 11.2.12 Update released for Drupal core (11.2.12)! drupal 11.3.10 Update released for Drupal core (11.3.10)! drupal 10.6.9 Update released for Drupal core (10.6.9)! drupal 10.6.8 Update released for Drupal core (10.6.8)! drupal 11.3.9 Update released for Drupal core (11.3.9)! drupal 11.3.8 Update released for Drupal core (11.3.8)! drupal 11.3.7 Update released for Drupal core (11.3.7)! drupal 11.2.11 Update released for Drupal core (11.2.11)! drupal 10.6.7 Update released for Drupal core (10.6.7)! drupal 10.5.9 Update released for Drupal core (10.5.9)! cms 2.1.1 Update released for Drupal core (2.1.1)!

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.

Activity

Total releases
4
First release
Sep 2025
Latest release
6 months ago
Release cadence
19 days
Stability
75% stable

Release Timeline

Releases

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