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 to Code
Learn any Language as a beginner
Develop a human edge in an AI powered world and learn to code with AI from our beginner friendly catalog
🏆 Leaderboard
Daily Coding Challenge
Solve a new coding challenge every day and climb the leaderboard

Free Resources

Copyright ©2025 Educative, Inc. All rights reserved