The drupal/section block should not use <main>

Created on 8 June 2025, 3 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

Production build 0.71.5 2024