Alert Dialog
A confirmation that interrupts on purpose — the same native <dialog> as the modal, with light dismiss switched off and alertdialog semantics. The whole diff is a few attributes.
dialogexit animations
Dialog vs Alert Dialog
An alert dialog interrupts to demand a decision, usually a destructive one, so a stray click on the backdrop must not dismiss it. Same element as Dialog but with a different dismissal policy.
How it works
closedby="closerequest"prevents the user from dismissing the dialog by clicking on the backdrop. This is also the default behavior in browsers withoutclosedbysupport, so the dismissal policy is identical everywhere<dialog>exists.role="alertdialog"tells screen readers this is an interruption that needs a response, and witharia-describedbypointing at the consequence text, the question is announced in full when the dialog opens.- Everything else — top layer, focus trap, inert background, the
overscroll-nonescroll-lock, the declarativecommandfortrigger, the entry/exit animation — is the Dialog verbatim.
Accessibility
Focus lands on the first focusable element when the dialog opens — here that’s Cancel,
because it comes first in the markup. That’s the right default for a destructive confirm: Enter
pressed out of reflex backs out instead of deleting. Keep the safe action first in source order.
Browser support
Minimum stable version per engine, resolved at build time from MDN's browser-compat-data; Baseline status from the official web-features dataset. Everything degrades gracefully — the “when missing” column is the actual behavior, not a broken page.
| Feature | Chrome | Edge | Firefox | Safari | When missing |
|---|---|---|---|---|---|
| <dialog> elementBaseline · widely available | 37 | 79 | 98 | 15.4 | Baseline, widely available. Modal behavior, focus handling and Esc-to-close are native. |
| Invoker commands (commandfor / command)‡Baseline 2025 · newly available | 135 | 135 | 144 | 26.2 | Buttons with commandfor do nothing. Until Baseline reaches your audience, open the dialog with a 3-line shim or from your framework. |
| Entry/exit animations (allow-discrete + @starting-style)†Baseline 2024 · newly available | 117 | 117 | 129 | 17.5 | Elements appear and disappear instantly. Nothing breaks — you just lose the animation. |
† @supports cannot test at-rules, so the badge checks transition-behavior: allow-discrete, which co-shipped with @starting-style in every engine.
‡ HTML feature — @supports can only test CSS, and we ship no JS to detect it, so it gets no live badge.