Skip to content

In development. Expect rough edges and changes. The source code is not public yet.

WebKit 3 min read How-to mediumAdept

Non-interactive Elements with the inert attribute

The HTML inert attribute disables focus, clicks, text selection and editing on an element and its descendants, and hides them from assistive technologies like aria-hidden="true". It replaces piecemeal workarounds such as disabled, tabindex="-1", pointer-events: none and user-select: none, each of which covers only part of the problem. A carousel example uses the inert DOM property in two lines to make inactive slides non-interactive, plus a CSS [inert] opacity cue. Support ships in Safari 15.5, Chrome 102 and Firefox Nightly, with a polyfill suggested for older browsers.

Assumes: HTML attributesDOM scriptingbasic CSS

Related posts

  • New WebKit Features in Safari 15.5

    WebKit easyNovice

    Safari 15.5 is mostly a polish and bug-fix release, adding three developer-facing technologies: the HTML `inert` attribute, which makes an element non-interactive and hides it from assistive technologies; the CSP Level 3 `worker-src` directive for restricting worker script sources; and WKWebView `minimumViewportInset`/`maximumViewportInset` APIs so apps can support the new CSS small, large and dynamic viewport units. A long list of fixes covers CSS (`position: sticky`, `aspect-ratio`, `background-clip: text`), Web APIs, CSP, media/HLS playback, WebRTC, WebGL multisampling, WebAuthn spec alignment and Safari extensions.

  • The Focus-Indicated Pseudo-class :focus-visible

    WebKit mediumAdept

    The :focus-visible pseudo-class lets authors style focus indicators only when the browser's own heuristics would draw one, such as during keyboard navigation or in text inputs, but not on a mouse click on a generic element. That fixes the common accessibility failure where :focus was used to remove outlines entirely. WebKit shipped it in Safari Technology Preview 138 alongside expanded Web Platform Tests, which aligned heuristics across engines; for example, clicking a div with tabindex=0 no longer shows an indicator. User agent stylesheets now use :focus-visible, so workarounds like :focus:not(:focus-visible) are no longer needed.

  • The golden rule of Customizable Select

    WebKit mediumAdept

    Customizable select, arriving in Safari 27, lets developers fully style `<select>` elements with custom arrows, icons and swatches while keeping native keyboard navigation and accessibility semantics. The one essential rule is to always give each `<option>` text content or an accessible text attribute. Icon-only options are harder for everyone to scan, unusable with screen readers and braille displays, and render as empty options in browsers without support or when CSS fails to load. Use visually hidden text or `alt` attributes where needed, mark decorative images with `alt=""`, and wrap enhancements in `@supports (appearance: base-select)` so plain text stays the baseline.

  • Introducing the Dialog Element

    WebKit mediumAdept

    Safari 15.4 beta and Safari Technology Preview 134 add the HTML `<dialog>` element, a native, accessible replacement for the script-blocking `alert`, `confirm` and `prompt` methods and for framework-built modals. Modal dialogs open with `showModal()`, lock interaction to the dialog and render above all content regardless of z-index. Non-modal dialogs open with `show()`, and both close with `close()`. `<form method="dialog">` closes the dialog on submit and sets `returnValue`. The backdrop is styled through `::backdrop`, and the element maps to `role="dialog"`/`aria-modal`, closes on Escape via a `cancel` event, and honors `autofocus`. Toggling the `open` attribute by hand is discouraged because it bypasses focus handling, and initial-focus behavior and the `inert` attribute are still being made interoperable under Interop 2022.

  • An HTML Switch Control

    WebKit mediumAdept

    Safari 17.4 adds a native HTML switch control via `<input type=checkbox switch>`, which falls back to a plain checkbox in browsers without support. It mirrors the checkbox API (`:indeterminate` never matches), uses the ARIA switch role with On/Off announcements and OS accessibility indicators, and supports vertical writing modes. It also honors `accent-color` on the track, and `appearance: none` resets all properties to initial values for full custom styling. Use a switch for on/off settings and a checkbox for selection. Experimental `::thumb` and `::track` pseudo-elements sit behind a feature flag pending standardization.

The quest for software engineering knowledge.

Look:
Layout: