Widely available Supported across all major browsers. Safe to use in production.

Browser support

Feature Desktop Mobile
Chrome
Edge
Firefox
Safari
Chrome Android
Safari iOS
105
105
103
15.6
105
15.6
1+Supported (version) Not supported Has note Sub-feature descriptions sourced from MDN Web Docs (CC BY-SA 2.5)

Syntax

CSS
dialog:modal {
  border: none;
  border-radius: 12px;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
  max-width: 480px;
}

dialog:modal::backdrop {
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(4px);
}

Live demo

modaldialog

:modal pseudo-class modaldialog demo.

PreviewFullscreen

background or effect

:modal pseudo-class background or effect demo.

PreviewFullscreen

fulskri-n style

:modal pseudo-class fulskri-n style demo.

PreviewFullscreen

Use cases

  • Using :modal

    The :modal CSS pseudo-class matches an element that is in a state in which it excludes all interaction with elements outside it until the interaction has been dismissed.

Cautions

  • May not be supported in older browsers.

Accessibility

  • Make sure visual changes are conveyed appropriately to assistive technology.