HTML inert Attribute

Beginner
6 min read
Updated: Nov 2026
3 examples
Live preview

Definition and Usage

The inert global boolean attribute marks an element as inert: the element and its descendants cannot be focused, clicked, or edited, and are typically skipped by assistive technologies — even when they remain visible on screen.

Use it to fence off background UI while a dialog or overlay is open. Prefer native <dialog> showModal() when a true modal is enough; add inert for custom overlays or extra control.

Baseline · Widely available.

Supported in modern Chrome, Firefox, Safari, and Edge.

Visibility is separate.

Inert content can still take space. Dim or hide it with CSS if you also need a visual backdrop treatment.

HTML Syntax

syntax.html
<element inert>

Boolean attribute — presence means true. Remove it (or set element.inert = false) to restore interaction.

Attribute Values

ValueDescriptionTry it
presentSubtree is inert (non-interactive / a11y-ignored)Try it
absentNormal interactionTry it

Live Preview

Toggle inert on a sample card. When inert, the button and link inside stop working.

Uses the real inert attribute / property.

Card

Sample interactive card

Learn inert

inert is off

HTML Examples

Example 1 — Mark a Region Inert

Add inert when a whole block should ignore input.

HTML
<section inert>
  <h2>Unavailable right now</h2>
  <button type="button">Edit</button>
</section>
Try It Yourself

How It Works

  1. Add the attribute. Presence freezes the subtree.
  2. No focus or clicks. Controls inside do not activate.
  3. Assistive tech skips it. The region is treated as non-interactive.
  4. Still visible. Layout can remain; style separately if needed.

Example 2 — Inert Page Behind an Overlay

Freeze the main app while a custom overlay is open.

HTML
<main id="app">...page content...</main>
<div id="dlg" role="dialog" aria-modal="true">Confirm?</div>
<script>
  document.getElementById("app").inert = true;
</script>
Try It Yourself

How It Works

  1. Keep the overlay outside the inert root so its controls still work.
  2. Set inert on open and clear it on close.
  3. Native showModal() already manages modality for <dialog>.
  4. Restore focus to a sensible control after unlocking.

Example 3 — Toggle with element.inert

Flip the reflected boolean property from a control outside the panel.

HTML
<button type="button" id="lock">Toggle inert</button>
<div id="panel">
  <button type="button">Action</button>
</div>
<script>
  lock.onclick = () => { panel.inert = !panel.inert; };
</script>
Try It Yourself

How It Works

  1. Put the toggle outside the inert subtree or it becomes unreachable.
  2. Assign the property. true adds inert; false removes it.
  3. Do not use inert="false". Presence still means inert for boolean attributes.
  4. Remember to unlock when the blocking UI closes.

Edge Cases & Pitfalls

Most bugs come from leaving inert on or nesting focus incorrectly.

focus

Focused elements lose focus

If focus is inside when you set inert, the browser moves it. Restore focus when unlocking.

nested

Cannot un-inert a child

A descendant stays inert while any ancestor is inert.

dialog

Native dialog modality

showModal() already makes the rest of the page inert-like. Extra inert is optional for custom overlays.

boolean

inert="false" still inert

Remove the attribute or set element.inert = false.

Browser Support

inert is an HTML attribute for browsers. It is not a Node.js, Deno, or Bun API.

✓ Baseline · Widely available

inert

Supported in modern Chrome, Firefox, Safari, and Edge.

96% Global support (approx.)
Google Chrome 102+
Full support
Mozilla Firefox 112+
Full support
Apple Safari 15.5+
Full support
Microsoft Edge 102+
Full support
Opera 88+
Full support
Samsung Internet 20+
Full support
Internet Explorer No support
Not supported
inert Widely supported

Bottom line: Safe for modern sites. Polyfill only if you must support very old browsers.

Key Takeaways

  • Role: freeze a whole subtree from interaction.
  • Not hidden: content can stay visible.
  • Not disabled: works beyond form controls.
  • Remember: remove inert when the overlay closes.

One line: inert freezes interaction for a subtree without necessarily hiding it.

Frequently Asked Questions

It makes the element and its descendants non-interactive: no click, focus, or edit, and assistive technologies typically ignore the subtree — even if it stays visible.
No. disabled is for form controls. inert applies to any element and freezes its whole subtree.
No. hidden removes content from presentation (often display:none). inert can leave content on screen while blocking interaction.
Commonly for the page behind a modal, custom overlays, off-canvas drawers, or temporary loading shells where interaction would be confusing.
No. pointer-events only blocks pointer hits. inert also blocks focus and assistive exposure.
Yes — widely available in modern browsers. Older browsers need a polyfill or progressive enhancement.

Next: inputmode

Hint which virtual keyboard layout to show for a field.

inputmode tutorial →

CODETOFUN NEWS

Stay Ahead in Tech

Get the latest IT news, programming updates, and technology trends directly on your phone.

Your daily dose of tech, straight to your feed.

About the author

Mari Selvan M P
Mari Selvan M P 🔗

Developer, cloud engineer, and technical writer

  • Experience 12 years building web and cloud systems
  • Focus Full Stack Development, AWS, and Developer Education

I write practical tutorials so students and working developers can learn by doing—from databases and APIs to deployment on AWS.

8 people found this page helpful