Problem/Motivation

Drupal core added a lot of WAI-ARIA roles to Drupal core (which is a good thing), but in the process lots of unneeded duplicates are added as well. A WAI-ARIA role is needed when the markup itself isn't clear. But markup like <nav role="navigation"> and <button role="button"> is superfluous since the HTML elements themselves already explain their role. Having these attributes makes HTML validation fail and we don't want that.

Proposed resolution

Remove all role attributes which duplicate semantics that are conveyed in another way.

Remaining tasks

Implement.

User interface changes

None.

Introduced terminology

None.

API changes

None.

Data model changes

None.

Release notes snippet

Issue fork drupal-2655794

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

BarisW created an issue. See original summary.

BarisW’s picture

Status: Active » Needs review
StatusFileSize
new15.3 KB
mgifford’s picture

I do agree 100% with

-    <main role="main">
+    <main>

Would like confirmation that all <aside> are role="complementary".

and <header> makes role="banner" redundant.

Thanks @BarisW

Version: 8.1.x-dev » 8.2.x-dev

Drupal 8.1.0-beta1 was released on March 2, 2016, which means new developments and disruptive changes should now be targeted against the 8.2.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.2.x-dev » 8.3.x-dev

Drupal 8.2.0-beta1 was released on August 3, 2016, which means new developments and disruptive changes should now be targeted against the 8.3.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.3.x-dev » 8.4.x-dev

Drupal 8.3.0-alpha1 will be released the week of January 30, 2017, which means new developments and disruptive changes should now be targeted against the 8.4.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

dimaro’s picture

Component: drupal.module » ajax system
StatusFileSize
new15.32 KB

The latest patch no longer applies.
Reroll against 8.4.x

feyp’s picture

Answering the questions from comment #3:

Would like confirmation that all <aside> are role="complementary". and <header> makes role="banner" redundant.

Regarding the <aside> element, https://www.w3.org/TR/html5/sections.html#the-aside-element says:

Allowed ARIA role attribute values:
complementary role (default - do not set), note, search or presentation.

Regarding the <header> element, https://www.w3.org/TR/html5/sections.html#the-header-element says:

Allowed ARIA role attribute values:
banner role (default - do not set) or presentation.

fwiw, the information about the default role of the <main> element can be found here:
https://www.w3.org/TR/html5/grouping-content.html#the-main-element

feyp’s picture

Component: ajax system » markup
Status: Needs review » Needs work

@dimaro, thanks for the reroll. The patch applies and looks good for the most part. However, there is still a

const header = document.querySelector('header[role="banner"]');

in core/themes/seven/js/mobile.install.es6.js after applying the patch. I guess that we need to remove the banner role for this query selector as well?

Also, I'm changing the category to markup since I guess your reassignment of the issue to the ajax subsytem was by accident.

pk188’s picture

Status: Needs work » Needs review
StatusFileSize
new15.99 KB

Fixed #9.
Check once for it's correctness.

pk188’s picture

StatusFileSize
new582 bytes

Interdiff for last patch.

feyp’s picture

Status: Needs review » Needs work

Thanks for working on this @pk188. By looking at the interdiff, I see you're changing the query selector from header[role="banner"] to header[]. Unfortunately, the latter is not a valid query selector, so you'll get a SyntaxError: 'header[]' is not a valid selector. You need to remove the square brackets as well to make it work (see the change in core/themes/seven/js/mobile.install.js for an example). Would you like to submit an updated version of your patch?

pk188’s picture

Status: Needs work » Needs review
StatusFileSize
new15.99 KB

Thanks for reviewing.
Here is new patch.

andrewmacpherson’s picture

Status: Needs review » Postponed
Issue tags: +Needs accessibility review

Thanks for re-rolling and checking this patch everyone.

We need to postpone this change, until we stop supporting Internet Explorer.

The issue is that IE does not pass the implicit ARIA landmark role to the host OS accessibility APIs. It only passes the landmark role if it is made explicit via the role attribute.

The good news is that it is fixed in Edge now. Firefox, Chrome, Safari, and Opera have handled implicit roles correctly for a long time already. I don't expect it to ever be fixed in IE 11.

The redundant value for the role attribute produces validation warnings, but not errors. It's clear from the HTML5 rec that is permitted valid markup. The "Do not set" advice is on the assumption that browsers will set the implicit ARIA role (emphasis mine):

In the majority of cases setting an ARIA role and/or aria-* attribute that matches the default implicit ARIA semantics is unnecessary and not recommended as these properties are already set by the browser. .

The point here is that Internet Explorer does not behave correctly. I've confirmed that users IE11 + NVDA screen reader will be adversely affected; the main/aside/header elements are not included in landmark navigation without the explicit role attribute.

dimaro’s picture

@andrewmacpherson @FeyP I only tried to bump this since the WAI-ARIA topic is a general "problem". The parent issue #2467827: [META] W3C validation for Drupal Core says the following:

Many clients, particularly administrations are paying attentions to following standards and may impose their site to be W3C compliant.

Regarding the above mentioned:

We need to postpone this change, until we stop supporting Internet Explorer.

Perfect! Thanks :)

andrewmacpherson’s picture

Issue tags: +Accessibility, +aria

Version: 8.4.x-dev » 8.5.x-dev

Drupal 8.4.0-alpha1 will be released the week of July 31, 2017, which means new developments and disruptive changes should now be targeted against the 8.5.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.5.x-dev » 8.6.x-dev

Drupal 8.5.0-alpha1 will be released the week of January 17, 2018, which means new developments and disruptive changes should now be targeted against the 8.6.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

andrewmacpherson’s picture

Title: Remove unneeded WAI-ARIA roles from <main>, <aside> and <header> elements » Remove redundant WAI-ARIA role attributes from <main>, <nav>, <aside>, <header>, and <footer> elements
Related issues: +#2939485: Redundant attribute role="navigation" in Stable/Classy/Seven theme's pager.html.twig

By my count we have at least 4 separate issues about this. I've been closing the others in favour of this one, which remains postponed until we drop IE support.

Updating the title to bring the nav & footer elements into scope here, because it's the same story for all of them. The implicit ARIA landmark roles have been mapped by all the browsers we support, except for IE.

pifagor’s picture

+1

Version: 8.6.x-dev » 8.7.x-dev

Drupal 8.6.0-alpha1 will be released the week of July 16, 2018, which means new developments and disruptive changes should now be targeted against the 8.7.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.7.x-dev » 8.8.x-dev

Drupal 8.7.0-alpha1 will be released the week of March 11, 2019, which means new developments and disruptive changes should now be targeted against the 8.8.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.8.x-dev » 8.9.x-dev

Drupal 8.8.0-alpha1 will be released the week of October 14th, 2019, which means new developments and disruptive changes should now be targeted against the 8.9.x-dev branch. (Any changes to 8.9.x will also be committed to 9.0.x in preparation for Drupal 9’s release, but some changes like significant feature additions will be deferred to 9.1.x.). For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

Version: 8.9.x-dev » 9.1.x-dev

Drupal 8.9.0-beta1 was released on March 20, 2020. 8.9.x is the final, long-term support (LTS) minor release of Drupal 8, which means new developments and disruptive changes should now be targeted against the 9.1.x-dev branch. For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

andrewmacpherson’s picture

Issue summary: View changes
chi’s picture

Version: 9.1.x-dev » 9.2.x-dev

Drupal 9.1.0-alpha1 will be released the week of October 19, 2020, which means new developments and disruptive changes should now be targeted for the 9.2.x-dev branch. For more information see the Drupal 9 minor version schedule and the Allowed changes during the Drupal 9 release cycle.

alison’s picture

Version: 9.2.x-dev » 10.0.x-dev
Status: Postponed » Active
Issue tags: -aria

Ready for status + version (issue metadata) update, now that IE11 support is officially being dropped with Drupal 10, ya?

(🎉🎉🎉🎉🎉🎉🎉)

shaal’s picture

Looks like it's time to revive this issue.
We should update Olivero and Claro templates as well.

nod_’s picture

Version: 10.0.x-dev » 10.1.x-dev
mherchel’s picture

gauravvvv’s picture

Status: Active » Needs review
StatusFileSize
new18.21 KB

Removed redundant WAI-ARIA role attributes. Attached patch for 10.1.x. please review

Status: Needs review » Needs work

The last submitted patch, 33: 2655794-33.patch, failed testing. View results

akshay kashyap’s picture

StatusFileSize
new17.1 KB
new18.79 KB

Here is new patch.

akshay kashyap’s picture

Status: Needs work » Needs review

Status: Needs review » Needs work

The last submitted patch, 35: 2655794-35.patch, failed testing. View results

gauravvvv’s picture

Status: Needs work » Needs review
StatusFileSize
new19.87 KB
new1.67 KB

Fixed failed tests. Attached interdiff for same. please review

smustgrave’s picture

Status: Needs review » Needs work
Issue tags: +Needs issue summary update, +Needs Review Queue Initiative

Changes for header and main look good

But title mentions footer and nav so I think the issue summary should be updated for what is being addressed

Also according to https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Roles/co... if there are multiple asides aria-label may be neded Do not implement yet as could be wrong assumption

catch’s picture

Copying over @andrewmcpherson's comment from #3117230-28: Remove redundant role="article" from <article> html tags

#26: Thanks for adding that WebKit issue. Indeed, IE11 isn't the only browser that has accessibility bugs. We certainly shouldn't remove these while we still support IE11, but even when we drop support for IE11, these role attributes will still need to be reassessed for the other browsers. Apple seem to have a lot of trouble keeping Safari and VoiceOver stable, particularly on iOS. Each new release of iOS has a different batch of accessibility bugs. I haven't kept a close watch on them all, but AppleVis has a good collection of them. That particular contentinfo bug is interesting, because it isn't clear whether the fault lies with WebKit, VoiceOver, or Apple's AX API.

The webkit issue is https://developer.mozilla.org/en-US/docs/Web/HTML/Element/footer#accessi...

Version: 10.1.x-dev » 11.x-dev

Drupal core is moving towards using a “main” branch. As an interim step, a new 11.x branch has been opened, as Drupal.org infrastructure cannot currently fully support a branch named main. New developments and disruptive changes should now be targeted for the 11.x branch, which currently accepts only minor-version allowed changes. For more information, see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

liam morland’s picture

liam morland’s picture

Status: Needs work » Needs review

I have opened a merge request with changes based on patch #38. The patch is old, so the code should be checked to see if there are any more attributes that need to be removed. Before doing this work, there should be agreement that this change should be made at this time or this issue should be postponed based on some criteria.

mherchel’s picture

heck yeah. There were lots that were missed, I pushed a fix for that.

Will ping @mgifford in Slack to see if he can signoff on the implementation.

mgifford’s picture

Great stuff. Looks great to me. Hopefully we can get it in before it's 10th anniversary – 24 Jan 2026 at 15:26 EST

liam morland’s picture

I made a small test update and they are now passing.

mherchel’s picture

Issue tags: +Needs change record
liam morland’s picture

Issue tags: -Needs change record

I have drafted a change record.

dcam’s picture

I wanted to review this as someone who finished writing a custom theme from scratch in the last year and had to remove some redundant roles.

The MR looks great and in the end it's just a bunch of small removals. I have no notes.

I did a search of Core for @role and role=["']. The remaining instances are not duplications of default roles.

What I'd personally like to see in the CR is a quick reference list of impacted templates. Here are some suggestions:

  • List only templates from the core modules, stable9, and the starterkit - any one that was likely to be extended and overridden.
  • Only list the impacted template names, since they're repetitive.
  • Just link to the MR change list.
liam morland’s picture

I have added the template list to the change record.

dcam’s picture

Status: Needs review » Reviewed & tested by the community

Yeah, that's good. Thank you. Now I know exactly what I need to go check in my themes. LGTM.

mherchel’s picture

I updated the title, and added reasoning to the CR. Thanks!

Version: 11.x-dev » main

Drupal core is now using the main branch as the primary development branch. New developments and disruptive changes should now be targeted to the main branch.

Read more in the announcement.

longwave’s picture

Status: Reviewed & tested by the community » Needs review

Wondering if we should be changing stable9 here? If someone is using stable9 and has CSS rules that include the role, this is a BC break for them. Even if this is considered a bug fix, I'm not sure we should be breaking stable9 in this way - it's only a redundancy and keeping it doesn't cause any actual issues that I can see.

mherchel’s picture

Good point. We should check with a framework manager.

mherchel’s picture

bnjmnm’s picture

Wondering if we should be changing stable9 here? If someone is using stable9 and has CSS rules that include the role, this is a BC break for them. Even if this is considered a bug fix, I'm not sure we should be breaking stable9 in this way - it's only a redundancy and keeping it doesn't cause any actual issues that I can see.

Good call. These changes should not be made in Stable 9 as they could result in user-impacting regressions. While the changes here could be categorized as a bug fix as it might appease some html validators, it does not improve any user facing or assistive tech functionality and does not seem to justify disrupting the Stable theme promise.

dcam’s picture

Status: Needs review » Needs work

Needs work per #55 and #58.

mherchel’s picture

Status: Needs work » Needs review

Easy enough change! Stable9 changes are now reverted.

dcam’s picture

Status: Needs review » Reviewed & tested by the community

I verified that the changes to stable9 were reverted.

  • longwave committed 75a55279 on 11.x
    fix: #2655794 Remove redundant WAI-ARIA role attributes from <main>,...

  • longwave committed 3fd5767a on main
    fix: #2655794 Remove redundant WAI-ARIA role attributes from <main>,...
longwave’s picture

Version: main » 11.x-dev
Status: Reviewed & tested by the community » Fixed

Let's do it. Not eligible for backport to 11.3.x just in case this breaks someone's CSS or JS somewhere.

Committed and pushed 3fd5767ae80 to main and 75a55279cc0 to 11.x. Thanks!

Also published the change record.

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.