dialog element
The native HTML element for dialogs; opened with showModal() it becomes an accessible modal with a backdrop and focus containment.
In more detail
It can also be opened with show(), which is not modal and does none of this. showModal() puts the dialog in the top layer above all other content, makes the page behind inert, closes on Escape while firing a cancel event, and returns focus to the previously focused element when it closes.
Related terms
- modal dialog — A window laid over the page that users must deal with before returning to the page beneath, with role="dialog" and aria-modal="true".
- focus trap — Code that keeps keyboard focus inside a container, such as an open modal, wrapping from the last element back to the first.
- top layer — A special layer the browser draws above everything else on the page, used for modal dialogs, popovers and fullscreen elements.
- inert content — Markup the browser has parsed but deliberately keeps dormant: nothing inside is displayed, fetched or executed.
Taught in
- Pointer Events, Focus Trapping And Keyboard Accessibility — Frontend Architecture & Web Platform
- Modern DOM Querying: querySelector, closest And matches — Frontend Architecture & Web Platform