The <dialog> Element
Technical Summary
The dialog element represents a temporary window in which a user performs a task or gathers information. show() displays a non-modal dialog; showModal() displays a modal dialog.
A dialog shown with showModal() enters the top layer and blocks the Document through that modal dialog. The focus sequence and the inertness of the outside page must be considered together with the visual presentation.
Removing open directly can bypass the close event, top-layer cleanup, modal blocking state, and focus restoration. Prefer close() or requestClose() for normal closing.
Definition / Categories
| Item | Normative organization |
|---|---|
| Meaning | A temporary dialog box for a task or information-gathering interaction |
| Categories | Flow content, Interactive content, and Palpable content |
| Context | Where flow content is expected |
| Content model | Flow content |
| Content attributes | Global attributes, closedby, and open |
| DOM interface | HTMLDialogElement with open, returnValue, show(), showModal(), close(), and requestClose() |
open state and showing methods
open is a boolean attribute indicating that the dialog is active and interactive. Its presence alone does not determine whether the dialog is modal.
| Operation | Normative boundary |
|---|---|
show() | Shows a non-modal dialog while the rest of the page remains interactive |
showModal() | Places the dialog in the top layer and shows it as the top-most modal dialog |
close(result) | Closes the dialog, stores the result as returnValue, and fires close |
requestClose(result) | Requests closing through cancel; if it is not canceled, the dialog closes |
const dialog = document.querySelector('#settings');
dialog.show(); // non-modal
dialog.close('done');
dialog.showModal(); // modal, top layer
dialog.requestClose('cancel');
Modality, the top layer, and inertness
A dialog shown by showModal() is added to the Document's open dialogs list and treated as modal. The Document is blocked by the dialog, and the outside focused area becomes inert. Because the dialog is in the top layer, its stacking behavior cannot be understood only through the ancestor's z-index.
The area behind the dialog can be styled through ::backdrop. A dark overlay alone does not implement modal semantics or keyboard behavior; the showing method, focus, and close conditions must be evaluated together.
<dialog id="confirm" aria-labelledby="confirm-title">
<h2 id="confirm-title">Confirm deletion</h2>
<p>This action cannot be undone.</p>
<form method="dialog">
<button type="submit" value="cancel" autofocus>Cancel</button>
<button type="submit" value="delete">Delete</button>
</form>
</dialog>
<style>
#confirm::backdrop { background: rgb(0 0 0 / 0.45); }
</style>
Focus, close requests, and events
The dialog focusing steps look for an autofocus target, a focus delegate, and then the dialog itself. If a particular descendant is the correct first interaction, authors should mark that intent with autofocus. When a modal closes, the user agent attempts to restore focus to the previously focused element.
close() is a direct close operation. requestClose() first fires a cancel event; unless it is canceled with preventDefault(), the close algorithm proceeds. This boundary allows Escape and other user close requests to share one cancellation point.
dialog.addEventListener('cancel', (event) => {
if (mustConfirm) event.preventDefault();
});
dialog.addEventListener('close', () => {
console.log(dialog.returnValue);
});
closedby and light dismiss
closedby is an enumerated attribute that defines which user actions close a dialog.
| Value | Close condition |
|---|---|
any | Close requests and clicks outside the dialog close it |
closerequest | Close requests close it, but outside clicks do not |
none | No user action automatically closes it |
| Missing or invalid | Auto; the computed closed-by state depends on conditions such as how the dialog was shown |
Support and outside-click behavior must be checked for the target browser set and date. The specified keyword and an observed close condition are not the same evidence.
Form method="dialog" and returnValue
When a form's method is in the Dialog state, form submission closes the dialog containing the form instead of making a network request. The submitter's value is used as the dialog's result.
<dialog id="ship">
<form method="dialog">
<button type="submit" value="board">Board the ship</button>
<button type="submit" value="call">Call the captain</button>
</form>
</dialog>
ship.addEventListener('close', () => {
if (ship.returnValue === 'board') {
// Continue according to the choice.
}
});
DOM Interface
HTMLDialogElement.open reflects the open attribute as a boolean. returnValue exposes the latest close result. The meanings of showing and closing should not be reduced to adding and removing an attribute.
const dialog = document.querySelector('#settings');
dialog.open;
dialog.returnValue;
dialog.show;
dialog.showModal;
dialog.close;
dialog.requestClose;
Fact / Evidence
Normative claims about meaning, showing methods, modality, focus, close requests, and form boundaries are separated from browser rendering, focus, and accessibility-tree observations in the Implementation Evidence section below.
| Type | Fact / claim | Condition / scope | Status | Source |
|---|---|---|---|---|
| SPEC | dialog represents a temporary dialog box for a task or information-gathering interaction. | Meaning, categories, context, content model, and usage boundary. | Reviewed | HTML Standard: dialog element |
| SPEC | show() is non-modal, while showModal() shows the dialog as a top-layer modal dialog. | open, modal state, Document blocking, and top layer. | Reviewed | HTML Standard: showing a dialog |
| SPEC | A modal dialog makes the focused area outside the dialog inert and places the dialog in the top layer. | showModal(), backdrop, focus, and modal blocking. | Reviewed | HTML Standard: modal dialog steps |
| SPEC | requestClose() goes through cancel and proceeds to the close algorithm unless canceled. | cancel, close, return value, and close requests. | Reviewed | HTML Standard: request to close |
| SPEC | method="dialog" closes the containing dialog and uses the submitter's value as the result. | Form method state, submitter, dialog close, and returnValue. | Reviewed | HTML Standard: form control infrastructure |
| SPEC | closedby represents any, closerequest, and none close conditions. | Computed closed-by state, modal behavior, and light dismiss. | Reviewed | HTML Standard: closedby |
Evidence
- HTML Standard: The dialog element — meaning, categories, content model, open, closedby, focus, show, showModal, close, requestClose, and the top layer
- HTML Standard: Form control infrastructure —
method="dialog", submitters, dialog closing, and result values - HTML Accessibility API Mappings — entry point for dialog roles, accessible names, states, and platform API mappings
- Web Platform Tests: the-dialog-element — related tests for dialog, modal, focus, close, and toggle behavior
Implementation Evidence
Browser implementation, WPT, and accessibility-tree observations are recorded separately from normative claims. dialog-v1 has been run in Chrome 153, and partial IMPL and accessibility-tree observations are registered. Unverified items are not marked as reviewed.
Dedicated fixture: dialog-v1 is a registered fixture for non-modal and modal display, initial focus, focus restoration, close requests, method="dialog", closedby, and returnValue. The fixture is stored in the repository as docs/atlas/dialog-v1-fixture.html and dialog-v1-check.js, with the execution record in docs/atlas/dialog-v1-results-2026-09-19.md.
| Type | Reproduction scope | Conditions to record | Status |
|---|---|---|---|
| IMPL | show() / showModal(), open, :modal, closedby, focus, close, and returnValue | Ran dialog-v1 on 2026-09-19 in Chrome 153.0.0.0 / Windows NT 10.0. Observed modal and non-modal display, initial focus, requestClose(), method="dialog", cancel / close, focus restoration, and return values. Backdrop, Escape, outside clicks, Firefox, and Safari were not run. | Partial observation (Chrome 153 / 9 checks passed) |
| WPT | Individual tests for dialog, modal state, focus, close requests, method=dialog, closedby, and toggle | Run selected files under the-dialog-element; record browser, date, pass/fail, and unrun reasons | Not run |
| AAM | Dialog role, accessible name, modal tree, inert background, and focus movement | Observed the named modal Confirm the action and non-modal Non-modal dialog, their headings and buttons, and initial focus in the Chrome 153.0.0.0 / Windows NT 10.0 accessibility tree on 2026-09-19. Assistive technology, platform APIs, other browsers, and unnamed dialogs were not run. | Partial observation (Chrome 153) |
Dialog placement, backdrop, Escape, outside clicks, focus, and accessibility-tree exposure may depend on the user agent, OS, attribute values, and showing method. A single-environment observation will not be registered as universal browser behavior.
Coverage / Open Issues
- CoveredMeaning, categories, context, content model, content attributes, and DOM interface
- Covered
show()/showModal(), modal blocking, top layer, focus, close requests, andmethod="dialog"as normative entry points - Covered
closedbyvalues, computed closed-by state, and the normative boundary for light dismiss - Partially covered
dialog-v1passed 9 checks in Chrome 153 on Windows NT 10.0; named modal/non-modal accessibility-tree states and initial focus were observed - OpenCross-browser comparison of focus, Escape, backdrop, outside clicks, close events, and focus restoration
- Open
closedby, command / commandfor, nested dialogs, popover interaction, implementation timing, and compatibility - OpenIndividual WPT results, complete HTML-AAM mappings, platform API observations, and assistive-technology differences
This is initial coverage. It records the normative processing model without claiming identical rendering, focus, close conditions, or accessibility API results across browsers, or completion of the entire dialog element review.
Related surface
For a beginner-friendly explanation of dialogs, modality, focus, and method="dialog", see the dialog element page in Yugien. For the opening control, see the button element; for the boundary with expandable information, see the details element; for shared form submission, see the form element.