What is <dialog> element in HTML?

The <dialog> element is used to define a dialog box, interactive component, or subwindow in a webpage. It allows the user to create popup dialogs and windows. The text to be shown in a dialog box is enclosed within <dialog> and </dialog> tags.

Attributes

The <dialog> tag supports global attributes, attributes common to all HTML elements (e.g. class, id, lang, title, etc.) It also supports event attributesattributes connected to action events (e.g., user clicks a piece of text.)
An important additional attribute is open. This tag indicates whether the dialog will be shown to the user of the webpage. When this attribute is not set, the dialog will not be shown to the user.

Code

The following code snippet shows how the <dialog> tag is used to create a dialog box.

New on Educative
Learn any Language for FREE all September 🎉
For the entire month of September, get unlimited access to our entire catalog of beginner coding resources.
🎁 G i v e a w a y
30 Days of Code
Complete Educative’s daily coding challenge every day in September, and win exciting Prizes.

Free Resources

Copyright ©2025 Educative, Inc. All rights reserved