Skip to content
WordPressRule: aria-hidden-focus•Reviewed Oct 2026

Prevent focusable elements inside aria-hidden containers in WordPress

Containers hidden with `aria-hidden="true"` must not contain links, buttons, or inputs that can receive keyboard focus.

What's wrong

Drawer carts, sliding mobile navigation panels, or modal dialogs that are closed often keep `aria-hidden="true"` while inner buttons remain in the tab order.

Who it affects

Keyboard navigators tab into invisible elements on the page while screen readers remain completely silent, causing disorientation.

How to fix on WordPress

In JavaScript mobile menu or modal scripts, add the `inert` attribute to closed off-canvas menus or toggle `display: none` when the drawer is collapsed.

Code example

Problematic Code
JAVASCRIPT
// Opening/closing mobile menu without managing inert
mobileMenu.setAttribute('aria-hidden', 'true');
Recommended Accessible Code
JAVASCRIPT
// Correctly disable focus when off-canvas is closed
mobileMenu.setAttribute('aria-hidden', 'true');
mobileMenu.setAttribute('inert', '');
mobileMenu.style.display = 'none';

How to check your fix

Close the drawer or modal, then press Tab repeatedly through the page. Verify that focus never lands on hidden links or buttons inside the closed panel.

Check if your site has this issue

Scan any public store page free against WCAG 2.2 AA in 30 seconds.

Your session has ended

Sign in again to carry on. Anything you typed on this page is kept.

Signed in another way? Use another method (opens a new tab)