Skip to content
easeweb
Search topics

aria-hidden content that keyboard focus still reaches

A closed slide-out menu is moved off screen and given aria-hidden="true", which hides its links from screen readers but leaves them all in the tab order.

WCAG 2.2
SC 4.1.2A
Required by
Section 508 · EN 301 549 (EU)
Broken <nav class="drawer" aria-hidden="true">
The accessibility problem illustrated: No vision:Where am I?
01

The problem

Keyboard and screen reader users land on links nobody can see or hear

02

Try it

Press Tab from the Menu button and follow the focus

With the menu closed, where does focus go after Menu, and what does a screen reader say there? Then open the menu and Tab through it.

Broken Can you fix this?

BrokenA closed menu hidden from screen readers only
Harbor & Pine

New this week

Linen tea towels in three colours, and a stoneware jug.

Read the journal

A recreated demo. The broken version is intentionally inaccessible.

03

The fix

Hide the closed menu from everyone at once

Before
BrokenA closed menu hidden from screen readers only
<button type="button" class="menu-button" aria-expanded="false" aria-controls="menu">Menu</button><nav id="menu" class="drawer" aria-label="Main" aria-hidden="true">  <a href="/shop">Shop</a>  <a href="/journal">Journal</a>  <a href="/about">About</a>  <a href="/contact">Contact</a></nav>
What is wrong3 points
  • Focus disappears for four presses of Tab: every link in the closed menu stays in the tab order, out of view.
  • Nothing hides the menu from the keyboard: transform hides it from sight, and aria-hidden only from screen readers.
  • At those four stops a screen reader says nothing, or only part of the link: focus lands on links without a name a screen reader will read.
After

The closed menu hidden with CSS

<button type="button" class="menu-button" aria-expanded="false" aria-controls="menu">Menu</button><nav id="menu" class="drawer" aria-label="Main">  <a href="/shop">Shop</a>  <a href="/journal">Journal</a>  <a href="/about">About</a>  <a href="/contact">Contact</a></nav>
How it is fixed3 steps
  1. Give the closed menu visibility: hidden. It hides the menu from sight, the keyboard, the pointer and screen readers at once.
  2. Delay visibility in the transition, so the menu slides out before it is hidden, and let the open state show it straight away.
  3. Take aria-hidden out of the markup and the script: it is no longer needed.

This fixes the Before and passes 4.1.2. When the menu doesn't animate, the hidden attribute does the same job: menu.hidden = !open.

Easily confused
04

Verify the fix

5 checks, no mouse.

Test with: Keyboard, Screen reader

0 of 5 checked

Record the OS, browser and assistive-technology versions, the build, the date, and the actual result of each step. Repeat after the shared menu, carousel or dialog component changes.

Limits

This is a starting pattern, not a guarantee for every application. It covers content hidden with aria-hidden that focus can still reach. aria-hidden on something that can't take focus but carries information people need, such as a price or a warning, is a different failure that this guide doesn't fix. ARIA that is misspelled or holds a value ARIA doesn't define is covered in invalid ARIA that misleads screen readers. What a screen reader says on a hidden link varies between browsers and screen readers, so test with the ones your users have.

This is a recreated teaching example, not a finding about a named client. The code is a starting pattern: test it in your own product. No completed assistive-technology test is claimed here.

EaseWeb service

Fixed it? Keep it from coming back.

I turn guides like this one into rules your coding agents follow and checks your CI runs. Then I retest by hand with a keyboard and screen readers, periodically.

See the service