I have created a html page when i do the accessibility testing i got some ARIA-landmarks suggesstions like below
Ensure all perceivable text is included in an ARIA landmark.
Using that i have added some landmarks for the heading tags like below
<div class="sign-up-title-container">
<h1 class="sign-up-title" role="heading" aria-level="1" aria-label="Sign up now" style="color: #000000; background-color: #fcb913">
Sign up now
</h1>
</div>
<div class="sw-cta-container-v1">
<p class="sw-cta-sub-text-v1" role="presentation" aria-label="Already a member?">
Already a member?
<span>
<a class="sw-cta-text-v1" role="button" aria-label="Log In" href="/en-us/login/?redir=/en-us/home/">Log In</a>
</span>
</p>
</div>
Based on the suggestions i have added the role as heading with aria-level="1" and aria-label="Sign up now"
But after running the test again i am facing the same message
Ensure all perceivable text is included in an ARIA landmark.
Not sure what i am doing wrong. Could anyone suggest me what is mistake i am doing.
2
Answers
The example code does not include any landmark, so the message will persist. The added ARIA attributes are harmful and deteriorating accessibility, you should probably remove them all.
From ARIA: landmark role on MDN, emphasis was added for this answer.
Since
landmark
is an abstract role, you need to use one of the derived roles for your section, likeform
orregion
.Any
<form>
is already a landmark role, and should have a helpful accessible name. This seems relevant to the example at hand, were two forms (sign-up and log-in) exist.This will provide a named landmark, that users of assistive technology can directly find in a list of page landmarks and navigate to it.
For the issues with the suggested ARIA attributes.
Using ARIA states some foundational rules:
Is explicitly defining the role and level again, that the
<h1>
element already has. It’s only a more verbose version and should be avoided. The same goes for the next part, which also achieves nothing different, as the accessible name of an element is by default it’s text contents:A
<p>
element has an implicit role ofparagraph
. By changing it to presentation, any semantics are taken away from this element, which makes navigating the document harder for users of assistive technology.Naming presentational elements is prohibited as per ARIA standard, so
aria-label
must be removed.This is taking away the
link
role that<a href>
already has. It helps users understand that interacting with the element will cause some form of navigation.Instead, the
button
role is applied:It can make sense to do so, if only visibility of a part of the UI is changed. “button or link” is covered to a large extend on the web.
@andy has some good info in his answer, especially regarding all the extra ARIA that was added to the code to try to "fix" the landmark issue.
You didn’t say what tool you used to scan the page to check the accessibility, but in any event, tools that recommend that all content be contained in a landmark is purely a suggestion and not a WCAG or accessibility requirement.
You’re certainly encouraged to have everything in a landmark but you don’t have to. If you do want landmarks, try to use native HTML elements first before resorting to adding a
role
. So your page structure might be something like this:All of these HTML elements have landmark roles: