Encodera

Thanks for reading!

Donate to the site — we work hard for you.

HTML & CSS reference

inert

Makes part of the page inactive: it cannot be clicked, reached with Tab or selected.

Syntax

<main inert>…</main>

Examples

The block is visible but does not respond:

<style>
  [inert] { opacity: 0.5; }
</style>
 
<div inert>
  <button>Can't click me</button>
  <a href="#">Can't follow me</a>
</div>
<button>But I work</button>

Notes

Handy when a side panel or a custom modal is open: make the rest of the page inert so focus cannot escape behind it. A built-in <dialog> opened with showModal() does this by itself. The attribute does not change the look — dim the block in CSS.

See also

  • hidden — Hides an element: it is not shown and not available to screen readers.
  • <dialog> — A dialog box; a modal one is opened with `showModal()` and blocks the rest of the page.
  • tabindex — Controls whether an element can be reached with the Tab key.

Related recipes

In the tutorial

  • Accessibility — How to make a page usable for everyone — keyboard use, focus, labels and alt, aria-label, contrast and meaningful tags.

Thanks for reading!

Donate to the site — we work hard for you.