hidden

Control element visibility and interactivity. Covers hidden, hidden='until-found', and inert — three levels of removing content from the user experience.

Overview

Three native attributes control whether and how users can see and interact with content. They represent three levels of removal from the user experience:

AttributeVisibleInteractiveIn Accessibility TreeFind-in-Page
hiddenNoNoNoNo
hidden="until-found"NoNoYesYes (reveals on find)
inertYesNoNoYes
(none)YesYesYesYes

hidden

The hidden attribute removes an element from rendering entirely. It behaves like display: none but is semantic — it declares that the content is not relevant to the current state of the page.

When to Use hidden

  • Conditional UI: Content that should appear only in certain states (logged in, feature enabled, etc.)
  • Template content: Fragments cloned by JavaScript
  • Deferred content: Content loaded after user interaction

hidden="until-found"

A newer value that collapses content visually but allows the browser to reveal it during find-in-page (Ctrl+F) searches. When a match is found inside, the browser fires a beforematch event and removes the hidden attribute.

This is useful for long FAQ pages, accordions, or collapsed sections where users should be able to search for content without expanding every section manually.

inert

The inert attribute keeps content visible but makes it completely non-interactive. Inert elements cannot be clicked, focused, selected, or found by assistive technology. The browser applies a visual dimming effect.

The form above is inert — try clicking or tabbing into it.

When to Use inert

  • Behind modals: Prevent interaction with page content while a dialog is open. Note: <dialog> with showModal() applies inert automatically.
  • Loading states: Disable a form section while a submission is in progress
  • Preview mode: Show content that shouldn't be interacted with yet
  • Step-by-step flows: Disable future steps until the current step is complete

JavaScript API

Both hidden and inert are reflected as boolean properties on the element.