Reusable and Interactive Markup
Dialog Open and Close
Native Modal Markup
A confirmation prompt uses dialog, the open attribute, and a method dialog form so the browser owns the close behavior.
Program
The dialog element gives HTML a built-in way to represent modal or non-modal prompts. The open attribute controls whether it is visible.
dialog_open_close.html
<button type="button">Show details</button>
<dialog open>
<h2>Confirm deploy</h2>
<form method="dialog"><button>Close</button></form>
</dialog>
dialog
A dialog element represents a prompt or modal surface.
method dialog
method="dialog" closes the dialog when its submit button is activated.