Avoid Focusable Elements Inside aria-hidden
Containers
Rule ID: aria-hidden-focus
Ruleset: axe-core 4.10
User Impact: Serious
Guidelines: WCAG 2.1 (A), WCAG 2.0 (A), WCAG 2.2 (A), Trusted Tester, EN 301 549
How to Fix the Problem
To fix this issue, ensure that no focusable elements are placed inside containers marked with aria-hidden="true"
. The aria-hidden="true"
attribute is intended to make content inaccessible to screen readers and assistive technologies. However, if any element inside such a container is still keyboard-focusable, it creates a confusing experience for users relying on assistive tech.
Steps to resolve:
-
Remove focusability of elements within
aria-hidden="true"
containers:-
Use
tabindex="-1"
to prevent keyboard focus. -
Use
disabled
for form controls if they are visually hidden. -
Use
display: none
orvisibility: hidden
for hidden links/buttons.
-
-
Do not attempt to reset
aria-hidden
on children. If a parent hasaria-hidden="true"
, then no descendant should try to override it witharia-hidden="false"
—this has no effect and leaves the content inaccessible.
✅ Correct examples (PASS):
❌ Incorrect examples (FAIL):
Why it Matters
Using aria-hidden="true"
removes an element and all of its children from the accessibility tree, making them invisible to screen readers and other assistive technologies.
However, focusable elements inside an aria-hidden="true"
container still respond to keyboard navigation (e.g., via the Tab
key). This causes a disconnection between what is seen, what is focusable, and what is announced, which can confuse users and lead to severe accessibility issues.
If assistive technology users can’t access the focusable element’s content—or worse, if it’s not announced at all—they may mistakenly believe something is broken or miss essential functionality.
Important: You cannot “undo”
aria-hidden="true"
on a child element. Once the parent is hidden, the child is hidden regardless of its own attributes.
Rule Description
This rule ensures that no element marked with aria-hidden="true"
contains any focusable descendants. Focusable elements must be accessible to all users, so they should never be hidden from assistive technology while still being keyboard-accessible.
The Algorithm (in simple terms)
-
Identify all elements with
aria-hidden="true"
. -
Check whether any of their child elements are focusable.
-
If any focusable child is found (e.g.,
<a>
,<button>
,<input>
, or any element withtabindex="0"
), the rule fails.