Interactive Elements
HTML <dialog> element
Represents a dialog or other interactive window. The open attribute displays a non-modal dialog; showModal() provides modal behavior, including top-layer placement. Open a modal using showModal(), or use show() for non-modal behavior. A modal enters the top layer and makes outside content inert. Provide an accessible name, sensible initial focus and a clear close action. Do not add tabindex to dialog itself. The open attribute alone does not create modal behavior; newer closedby behavior must be checked separately. Global attributes apply, except tabindex must not be used on dialog.
Formal Syntax & Structure
html syntaxhtml
<dialog>Dialog content</dialog>Parameters & Attributes
| Name | Type | Description |
|---|---|---|
| open | boolean | An open attribute alone shows a nonmodal dialog. Use showModal() for modal behavior; do not remove open directly to close a modal. |
| closedby | enumerated: any, closerequest, none | Controls allowed user-initiated dismissal of a dialog. any also permits light dismissal; closerequest allows platform close requests; none relies on author-provided controls. Check compatibility separately from dialog itself. |
Return Value
HTMLDialogElement
Content model: Flow content.
Working Example
Example Snippethtml
<!doctype html><html lang="en"> <head> <meta charset="utf-8"> <title>Delivery details</title> </head> <body> <button type="button" id="open">Show details</button> <dialog id="info" aria-labelledby="info-title"> <h2 id="info-title">Delivery details</h2> <p>Delivery takes two days.</p> <form method="dialog"> <button>Close</button> </form> </dialog> <script> document.getElementById("open").onclick=()=>document.getElementById("info").showModal(); </script> </body></html>Browser Compatibility
Minimum supported versions across modern rendering engines
Widely Available (2022)
Blink (modern)
Chrome
37
Yes
Gecko
Firefox
98
Yes
WebKit
Safari
15.4
Yes
Basic dialog element support; newer dismissal attributes have separate support.
HTML Living Standard