CSS Reference ยท Scrolling, Interaction and UI
The interactivity property
Reference for the CSS interactivity property, which makes a subtree inert from a style sheet. Support is limited, so see how to use it with the inert attribute.
The interactivity property lets a style sheet mark an element and everything inside it as inert. An inert subtree cannot be clicked, focused, selected or found with the browser's find-in-page, and it is hidden from assistive technology as if it were not interactive content at all. It is the CSS counterpart of the HTML inert attribute.
This property is new and has limited browser support. Treat it as an enhancement, and use the inert attribute when you need the behavior everywhere.
.modal-open main { interactivity: inert; }
Try it
In either case the second panel ends up inert: through CSS where the property exists, through the attribute where it does not.
Syntax
interactivity: auto | inert
- Initial value:
auto - Applies to: all elements
- Inherited: yes
- Animatable: no (the values switch discretely)
- Computed value: as specified
Values
| Value | Description |
|---|---|
auto |
Normal behavior: the element is interactive unless something else (such as the inert attribute or a modal dialog) makes it inert. |
inert |
The element and its descendants are inert. They cannot receive focus, clicks or text selection, and they are excluded from find-in-page and from assistive technology's view of interactive content. |
Usage notes
- Same effect as the attribute.
interactivity: inertis meant to do what<div inert>does. If you already use the attribute, you do not need the property. - Why a CSS version? State often lives in classes (for example "dialog open" or "loading"). Driving inertness from a selector avoids JavaScript that has to add and remove an attribute.
- Inherited, but not undoable by children. An inert subtree cannot contain an interactive child. A descendant with
interactivity: autois still inert while an ancestor is inert, unlikepointer-eventswhere a child may opt back in. - Pair it with visual feedback. Inert content looks normal by default. Dim it, as in the example, so sighted users can see that it is unavailable.
- Use real disabling for forms. For form controls that should not be submitted, use the
disabledattribute. Inertness stops interaction but does not change the form data. - Feature-detect. Use
@supports (interactivity: inert)orCSS.supports(), and keep aninertattribute fallback for anything important. - Compared with
pointer-events.pointer-events: noneblocks only the mouse, touch and pen. Inertness also blocks the keyboard and assistive technology.
Browser support
Limited: this property is very new and not available in all major browsers; check a compatibility table and rely on the HTML inert attribute for production behavior.
Related
pointer-eventsโ blocks pointer input onlyuser-selectโ controls text selectionvisibilityโ hides an element without changing layout:modalโ modal dialogs make the rest of the page inert- Lesson: Accessibility