CSS :modal Pseudo-Class

Beginner
2 examples
Updated: Nov 2026

Definition and Usage

The :modal pseudo-class matches an element that is in a modal state, blocking interaction with the rest of the page—most commonly an open <dialog> shown with showModal().

CSS Syntax

syntax.css
dialog:modal {
  border: none;
  border-radius: 12px;
}

Key Uses

PatternPurposeTry it
:modalElement currently shown as a modalTry it
with ::backdropStyle the dimmed backdrop behind itTry it

CSS Examples

Style an open dialog

example.css
dialog:modal {
  padding: 1.25rem;
  border-radius: 12px;
  border: none;
}
Try It Yourself

Browser Support

:modal is a CSS selector.

✓ Selectors

:modal

Supported in modern browsers.

94% Modern browsers
Google Chrome Recent
Full support
Mozilla Firefox Recent
Full support
Apple Safari Recent
Full support
Microsoft Edge Recent
Full support
:modal Modern support

Bottom line: Safe for modern sites. Keep readable defaults without the selector.

Frequently Asked Questions

Elements presented in a modal state, typically dialog via showModal().
No. dialog.show() without modal presentation does not match :modal.
Use the ::backdrop pseudo-element on the modal element.
Modern browsers support dialog and :modal natively.
::backdrop styles the layer behind the modal.

Next: :popover-open

Continue with :popover-open.

:popover-open →

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.

2 people found this page helpful