w3c / wai-website

This repository hosts the WAI Website.
https://www.w3.org/WAI/
Other
60 stars 296 forks source link

HTML elements should not have redundant roles #598

Open gnpivo opened 6 months ago

gnpivo commented 6 months ago

Hi. The Page Regions in HTML5 Using WAI-ARIA section suggests using both the HTML element and its corresponding role:

<header role="banner">…</header>
<main role="main">…</main>
<nav role="navigation">…</nav>
<footer role="contentinfo">…</footer>

However, the ARIA in HTML recommendation specifically discourages this usage:

The following example illustrates a button element which has also been provided an explicit role=button. Specifying this role is unnecessary, as a "button" element is already exposed with an implicit button role. In practice this particular instance of redundancy will likely not have unforeseen side effects, other than unnecessarily making the markup more verbose, and incorrectly signaling to other authors that this practice is useful. Please review the section 3.3 Be cautious of side effects for an example of where specifying unnecessary roles can be problematic.

<!-- Avoid doing this! -->
<button role="button">...</button>

I believe the tutorial should be modified to conform with the recommendation by not encouraging the use of redundant roles.

brianelton commented 6 months ago

I agree. This section could probably be removed completely. The HTML4 section provides sufficient information for the use of ARIA roles when HTML5 can not be used.