The drupal/section block should not use <main>

Created on 8 June 2025, 4 months ago

This is very similar to The drupal/section block should use configurable element Needs work , with the same reasons:

When using the drupal/section block provided by this module the resulting output contains the HTML element. There should only ever be one of these as it is a landmark role in ARIA and at the same level as other landmarks

Most Drupal themes + core includes a <main> section further up in the DOM, which I'd argue in the vast majority of cases would be more correct. Also, <main> can not be below <article>, which is a thing that can typically happen here, and will cause validation errors.

In comparison with the issue above, I think it is overly complex to make this configurable. That would also create a need to have a UI to configure it on the block instance.

I suggest one of two alternative directions:

  • Just change it from main to div, and make a deprecation. This could however lead to regressions if people have js or css attached to the main element instead of the class, so maybe better to move to a major version (?)
  • Change the block to a dynamic block, add a deprecation, and add a template file with the main element in, so people can change it to their liking using a template override.
📌 Task
Status

Active

Version

3.0

Component

User interface

Created by

🇳🇴Norway vegardjo

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

  • Issue created by @vegardjo
  • Merge request !221Resolve #3529010 "The drupalsection block" → (Open) created by vegardjo
  • Pipeline finished with Success
    4 months ago
    Total: 445s
    #522777
  • 🇳🇴Norway vegardjo

    Here's a PR adding a template file with the main tag, not breaking any markup, but adding flexibility to override it in your custom theme.

    In a future major version (4?) I'd still suggest changing the template file to use a div, as this will be correct in most cases.

  • Pipeline finished with Success
    28 days ago
    Total: 555s
    #597835
  • Pipeline finished with Failed
    28 days ago
    Total: 401s
    #597851
  • Pipeline finished with Canceled
    28 days ago
    Total: 288s
    #597857
  • Pipeline finished with Success
    28 days ago
    Total: 666s
    #597859
  • Pipeline finished with Success
    27 days ago
    Total: 357s
    #598386
  • Pipeline finished with Failed
    1 day ago
    Total: 703s
    #624031
Production build 0.71.5 2024