Accessibility
ARIA hidden element must not contain focusable elements
Using the aria-hidden="true"
attribute on an
element
removes the element and ALL of its child nodes from the accessibility API making it completely
inaccessible to screen readers and other assistive technologies.
Aria-hidden may be used with extreme caution to hide visibly rendered content from assistive technologies only if the act of hiding this content is intended to improve the experience for users of assistive technologies by removing redundant or extraneous content. If aria-hidden is used to hide visible content from screen readers, the identical or equivalent meaning and functionality must be exposed to assistive technologies.
Note: Using aria-hidden="false"
on content that is a descendent
of an element that is hidden using aria-hidden="true"
will NOT expose that
content to the accessibility API and it will not be accessible to screen readers or other
assistive technologies.
The rule applies to any element with an aria-hidden="true"
attribute.
By adding aria-hidden="true"
to an element, content authors ensure that
assistive technologies will ignore the element. This can be used to hide decorative parts of
a web page, such as icon fonts - that are not meant to be read by assistive technologies.
A focusable element with aria-hidden="true"
is ignored as part of the reading
order, but still part of the focus order, making it’s state of visible or hidden unclear.
https://www.w3.org/WAI/WCAG21/Understanding/name-role-value.html
Fixing the problem
Fix the issue by ensuring the value inside each attribute is spelled correctly and corresponds to a valid value. Use appropriate ARIA roles, states, and properties.
The following examples PASS the aria-hidden="true"
elements do not contain
focusable elements rule:
-
Content not focusable by default.
<p aria-hidden="true">Some text</p>
-
Content hidden through CSS.
<div aria-hidden="true"> <a href="/" style="display:none">Link</a> </div>
-
Content made unfocusable through tabindex.
<div aria-hidden="true"> <button tabindex="-1">Some button</button> </div>
-
Content made unfocusable through disabled.
<input disabled aria-hidden="true" />
-
aria-hidden
can’t be reset once set to true on an ancestor.<div aria-hidden="true"> <div aria-hidden="false"> <button tabindex="-1">Some button</button> </div> </div>
The following examples FAIL the aria-hidden="true"
elements do not contain
focusable elements rule:
-
Focusable off screen link.
<div aria-hidden="true"> <a href="/" style="position:absolute; top:-999em">Link</a> </div>
-
Focusable form field, incorrectly disabled.
<div aria-hidden="true"> <input aria-disabled="true" /> </div>
-
aria-hidden
can’t be reset once set to true on an ancestor.<div aria-hidden="true"> <div aria-hidden="false"> <button>Some button</button> </div> </div>
-
Focusable content through
tabindex
.<p tabindex="0" aria-hidden="true">Some text</p>
-
Focusable summary element.
<details aria-hidden="true"> <summary>Some button</summary> <p>Some details</p> </details>