<dialog>
InteractiveRepresents a dialog box, modal, or popup that overlays the page content. Can be shown modally or non-modally via JavaScript.
Common Attributes
openExample
<dialog id="myDialog">
<h2>Confirm</h2>
<p>Are you sure?</p>
<button onclick="this.closest('dialog').close()">Close</button>
</dialog>About the <dialog> Element
The <dialog> HTML element belongs to the Interactive category of HTML elements. Represents a dialog box, modal, or popup that overlays the page content. Can be shown modally or non-modally via JavaScript. Understanding when and how to use this element is essential for building well-structured, accessible, and SEO-friendly web pages.
The <dialog> element requires both an opening <dialog> and closing </dialog> tag. Content placed between these tags becomes the element's children. This element is part of the current HTML Living Standard and is supported in all modern browsers including Chrome, Firefox, Safari, and Edge.
Proper use of semantic HTML elements like <dialog> improves document structure, helps screen readers interpret content correctly, and provides signals to search engines about the purpose of different sections of your page. This leads to better accessibility scores, improved SEO rankings, and more maintainable code.