Li Jiabao
Display: Static中文 以中文閱讀本頁

Edited by lijiabao.dev

Hidden, aria-hidden and inert solve different interface problems

Separate visual presentation, accessibility exposure and interaction when choosing hidden, aria-hidden or inert. Verify each behavior without treating hidden content as access control.

Describe the state before choosing an attribute

An interface can look closed while its controls remain reachable. It can also look available while important information has disappeared from accessibility APIs. These are different failures, even when a developer describes both as hidden content. Choosing between hidden, aria-hidden and inert starts with the behavior the component needs. The scenarios below are hypothetical review examples, not a claim that this site has changed its components or completed assistive-technology testing.

A keyboard and monitor showing an abstract dialog above a muted interface, with headphones and a testing notebook beside them

Imagine a booking interface with a collapsible explanation and a confirmation dialog. Closing the explanation may mean that its content should no longer be presented. Opening the dialog may leave the page behind it visible while preventing interaction with that background. The same visual design language does not make these the same requirement.

A useful brief says what a visitor can see, reach and understand in each state. It also identifies where focus is before and after a change. That brief gives a reviewer something observable to check. A request to hide the panel leaves too many choices unresolved, particularly when the panel contains links, errors or other controls.

Use hidden for presentation, with attention to its actual state

The ordinary hidden state indicates that content should not currently be presented. It usually removes that content from the rendered layout. The attribute is enumerated rather than a JavaScript-style switch: assigning the text false is not a reliable way to turn it off. Authors should use the appropriate attribute state instead of guessing from the word’s appearance.

There is also a distinct until-found state, which can allow find-in-page or fragment navigation to reveal content. Styling can affect the eventual presentation as well. Consequently, reviewing the source attribute alone is insufficient. Check the chosen state, the resulting styling and the supported browsers before claiming that a section is consistently unavailable to visitors.

Do not mistake aria-hidden for visual hiding or disabling

Setting aria-hidden to true removes an element and its children from accessibility exposure. It does not itself make the pixels disappear or disable the controls. A visible button that remains in the focus sequence while being hidden from accessibility APIs is therefore a warning sign, not a complete implementation of a closed interface.

Use particular care with ancestors of focusable elements. Setting a child to false does not undo a hidden ancestor. For decorative or duplicated content, first establish that equivalent meaning and functionality remain available. Removing redundant material can help, but removing a warning or a control’s useful description can create a mismatch between what different visitors encounter.

Use inert when a region must stop participating in interaction

An inert region and its relevant descendants cannot be focused or clicked in the usual interactive way and are removed from the tab order and accessibility tree. This addresses a different need from changing presentation alone. It does not automatically supply a visual treatment explaining why a region is unavailable.

That distinction matters when the dimmed background of a dialog still resembles an active page. Visitors need understandable cues in addition to the underlying behavior. Native modal dialogs have specific rules, so authors should review the component and its APIs rather than assuming that every descendant behaves identically in every situation. For a single control, an appropriate native disabling mechanism may be a better fit than disabling an entire region.

Treat focus and state changes as part of the component

For the hypothetical collapsible explanation, ask how the trigger communicates its state and what happens if focus is inside the content when it closes. Making a panel transparent does not answer whether its links remain in the keyboard sequence. Similarly, removing a region from an accessibility tree does not define where a person’s next action should go.

A confirmation dialog introduces its own entry, background-interaction and return-focus questions. Prefer suitable native elements and an established interaction pattern, then verify the behavior needed by the actual design. W3C guidance emphasizes that adding ARIA semantics does not supply the keyboard interaction a role promises. A role and a convincing screenshot cannot replace the missing behavior.

Keep access control at the data boundary

None of these mechanisms is an authorization system. If private information has already been delivered to a browser, making its container invisible is not a dependable way to keep it confidential. The server’s decision to provide data and the client’s decision to display a region are separate concerns.

For a hypothetical restricted panel, review whether an unauthorized request receives information it should not have, and separately review whether the interface presents the permitted actions correctly. Use authorized test identities and appropriate environments. There is no reason to borrow another person’s account or expose real customer material merely to demonstrate this distinction. An untested data boundary should remain recorded as unverified.

Collect separate evidence for separate behaviors

A focused acceptance pass can inspect the open and closed visual states, walk the relevant task with a keyboard, and examine accessibility information and the assistive-technology combinations appropriate to the audience. Those observations answer different questions. A screenshot without a button does not prove that keyboard users cannot reach it; an absent accessibility node does not prove that its data was never sent.

Automated checks can support this work when their assertions correspond to the requirement. A rule that catches one focusable hidden control is useful evidence about that rule, not a certificate that every interaction is accessible. Record the browser, state and relevant environment, and keep the scope proportional to the change rather than accumulating unrelated passing checks.

Report the verified scope instead of an accessibility label

A practical handoff explains which state changed, why the chosen mechanism fits, what was observed and what remains untested. If the work only inspected DOM attributes, say so. Do not describe it as completed screen-reader acceptance. If a particular browser and assistive-technology pairing was tested, preserve that pairing instead of generalizing to every visitor.

When the layers disagree, revisit the intended behavior and repair the relevant part. Adding another hiding attribute to suppress the symptom can make the mismatch harder to understand. This article offers a way to reason about an implementation, not a complete component recipe or a claim about search rankings. The result becomes maintainable when each completion statement is tied to evidence that actually supports it.

Choose a mechanism after deciding what should be presented, exposed and interactive. Then verify those behaviors independently. Keeping the distinctions visible in the review prevents one successful screenshot from standing in for keyboard behavior, accessibility semantics and authorization.

Related reading: Passing tests is a start: what proves a feature is complete?; A 200 response does not prove an article was published

Sources

  1. MDN: hidden(external site) developer.mozilla.org
  2. MDN: aria-hidden(external site) developer.mozilla.org
  3. MDN: inert(external site) developer.mozilla.org
  4. HTML Standard: Inert subtrees(external site) html.spec.whatwg.org
  5. W3C ARIA Authoring Practices Guide: Read Me First(external site) w3.org