HTML <dialog>
Tag
The <dialog>
tag represents a dialog box or other interactive component such as a popup menu. It can be used to create modal dialogs, alerts, or custom user interface components.
How it works:
When the <dialog>
element is added to the HTML document, it is hidden by default. You can use JavaScript to show and hide the dialog box as needed. When the dialog is open, it blocks the user from interacting with the rest of the page until it is closed.
Example:
<dialog id="myDialog">
<p>This is a dialog box</p>
</dialog>
<button onclick="document.getElementById('myDialog').showModal()">Open Dialog</button>
Main Tag Attributes:
Attribute | Description |
---|---|
open |
Specifies whether the dialog box is open or closed. Can be set to "open" to show the dialog initially. |