SyntaxStudy
Sign Up
Home HTML Reference <dialog>

<dialog>

tag HTML5

Represents a dialog box or modal window. Can be opened with the open attribute or showModal() method.

Syntax

<dialog id="modal"> ... </dialog>

Example

html
<button onclick="document.getElementById('dlg').showModal()">Open Dialog</button>

<dialog id="dlg">
    <h2>Confirm Action</h2>
    <p>Are you sure you want to delete this item?</p>
    <form method="dialog">
        <button>Cancel</button>
        <button value="confirm">Confirm</button>
    </form>
</dialog>