Knowledge baseExam Center
ENEnglish
Choose language13

CKTIS / HTML

HTML term or value: inert

The `inert` attribute disables user interaction with an entire subtree, including focus and activation, while leaving its nodes and application state in the DOM.

Version: WHATWG HTML Living Standard; index snapshot date recorded separately

Syntax

<section inert><button>Unavailable</button></section>

inert is a boolean attribute, so presence enables the state; inert="false" still means active inert. The state covers flat-tree descendants, which cannot be focus or user-click targets and are omitted from assistive-technology exposure.

Authors must not leave visibly perceivable inert content looking operable: hide or appropriately obscure it so the inactive state is unambiguous. A modal opened with showModal() escapes ancestor inertness unless the dialog itself has inert, and makes the rest of the document inert; for one form control, native disabled may be right.

Inertness does not remove content, stop scripts, or form a security boundary; form values can remain and code can mutate the DOM. When restoring interaction, remove the attribute only after synchronizing the visible state and intended focus location.

The example calls focus() on a button inside the inert subtree, but document.activeElement remains the previous button; the inert property is true, and the inner node still exists in the DOM.

Examples

<!doctype html><meta charset="utf-8"><button id="before">Before</button><section id="x" inert><button id="inside">Inside</button></section><output id="result"></output><script>before.focus();inside.focus();result.textContent=`inert=${x.inert}; active=${document.activeElement.id}; inDom=${document.body.contains(inside)}`;</script>

Result

inert=true; active=before; inDom=true

The executed example verifies rejection of a programmatic focus attempt without removal of the descendant from the document.

Sources