A hand-built modal has a lot to get right — trapping Tab inside it, closing on Esc, dimming the background, and wiring `role="dialog"` and `aria-modal` correctly for screen readers. Miss any one of these and it's an accessibility bug.
`<dialog>` solves this at the element level. Calling `.showModal()` renders it in the top layer, traps focus automatically, closes on Esc, and exposes a `::backdrop` pseudo-element for styling the scrim. Worth knowing: `.show()` (modeless) differs from `.showModal()` (modal), and a form with `method="dialog"` closes the dialog automatically on submit.
Check caniuse/MDN baseline for support. Without it, a custom modal with hand-rolled focus trapping, an Esc listener, and a backdrop div is the fallback — and still used today when animation needs go beyond what `<dialog>` offers.
When to use
Building a screen-blocking confirmation or settings modal quickly, without accessibility bugs.