Focusable element inside aria-hidden (aria-hidden-focus)

The aria-hidden-focus rule flags content hidden from assistive technology with aria-hidden="true" that can still receive keyboard focus. A screen reader user tabs onto a link that, as far as their software is concerned, does not exist – and hears nothing, or something out of context. The fix is to hide the content from the keyboard as well, usually with the inert attribute.

What the rule means

aria-hidden="true" removes an element and everything inside it from the accessibility tree. It does not remove anything from the tab order. So a link inside still takes focus when somebody presses Tab, but assistive technology has been told to ignore it: its name, its role and its purpose are gone. That breaks 4.1.2, which requires every control to expose a name and a role.

The rule passes when every focusable element inside an aria-hidden container is taken out of the tab order – by inert, disabled, tabindex="-1" or by hiding it with display: none or visibility: hidden.

Who is affected

Screen reader users first: focus lands somewhere their software refuses to describe. Sighted keyboard users are affected too when the hidden content is also off-screen, because every Tab stop in a closed menu is one they cannot see.

Why the check fails

  • Off-canvas menus marked aria-hidden="true" while closed, with their links still tabbable.
  • Modal dialogs that set aria-hidden on the page behind them but leave its links in the tab order.
  • Carousels that hide inactive slides with aria-hidden while their links and buttons stay focusable.
  • Decorative wrappers around icons that contain a real link or button.
  • Copies for animation – a duplicated marquee or ticker hidden from screen readers, links included.

How to fix it

Use inert on anything you hide: it takes the content out of the tab order and out of the accessibility tree in one attribute, and it is supported in all current browsers.

<!-- Before: hidden from screen readers, still reachable by Tab -->
<nav class="offcanvas" aria-label="Menu" aria-hidden="true">
  <a href="/shop/">Shop</a>
  <a href="/account/">Account</a>
</nav>
<!-- After: inert hides it from both, until the menu opens -->
<nav class="offcanvas" aria-label="Menu" inert>
  <a href="/shop/">Shop</a>
  <a href="/account/">Account</a>
</nav>

When the menu opens, remove inert again (menu.inert = false). For a modal, <dialog> opened with showModal() makes the rest of the page inert for you. If you must keep aria-hidden, set tabindex="-1" on every focusable child – and remember to restore it.

How to test it manually

  1. Close every menu, dialog and carousel slide, then press Tab through the page. Does focus land on anything you cannot see?
  2. In the browser's developer tools, inspect the focused element's accessibility properties. "Ignored" or no name means it is hidden from assistive technology.
  3. With a screen reader running, tab through the same places and listen for silence or out-of-context links.
  4. Open the components again and check that their content is reachable once visible.

4.1.2 Name, Role, Value, Level A. Related: 2.4.3 Focus Order, because focus visits content that is not really there, and 1.3.1 Info and Relationships.

How Reviseberg reports it

Reviseberg runs aria-hidden-focus on every crawled page. The issue list shows the rule with its severity, WCAG 4.1.2, the number of affected elements and pages, and the points a fix gets you back; the detail view shows the selector and HTML snippet of the hidden container. Because the cause is usually one component in the template, one fix often clears every page at once. Where the hidden content is also off-screen, the keyboard agent's walk may show the same menu as undefined on the journey you define.

  • undefined – focus on something nobody can see.
  • undefined – a dialog without a name.
  • undefined – focusable content where assistive technology does not expect it.

Check your menus and dialogs – get a free scan

Frequently asked questions

Is aria-hidden="true" on an icon wrong?

No. Hiding a decorative icon is correct – as long as the icon itself is not focusable and does not contain a link or button.

Why is inert better than tabindex="-1"?

inert covers everything inside, including content added later, and also blocks mouse clicks. tabindex="-1" has to be set, and removed again, on every single element.

Does display: none pass the rule?

Yes. Content that is not displayed cannot take focus. It is the right choice when the hidden content does not need to animate.

Sources

  1. W3C, Understanding SC 4.1.2 Name, Role, Value – https://www.w3.org/WAI/WCAG22/Understanding/name-role-value
  2. Deque University, axe-core 4.13 rule aria-hidden-focus – https://dequeuniversity.com/rules/axe/4.13/aria-hidden-focus
  3. W3C, WAI-ARIA 1.2: aria-hidden – https://www.w3.org/TR/wai-aria-1.2/#aria-hidden
  4. MDN, HTML inert global attribute – https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/inert

See what a scan finds on your site

One page in about thirty seconds, no email needed. The full report covers up to 100 pages and a keyboard journey.