How to fix: hidden elements can get focus
WCAG 2.2 success criterion 4.1.2 (level A)
Why it matters
Keyboard users land on things screen readers say do not exist.
How to fix
Add tabindex="-1" or remove focusable elements inside aria-hidden="true".
<div aria-hidden="true"><a href="#" tabindex="-1">…</a></div>
Test it yourself
- Open the hidden element (closed menu, off-screen cart), then press Tab: focus must not land on anything you cannot see.
Common mistakes
- Hiding a closed menu with aria-hidden="true" but leaving its links focusable.
- Carousels that set aria-hidden on inactive slides but not tabindex="-1" or inert on their links.
Check your own site
Find this and other problems on your website in 30 seconds, free.