Open In App

HTML5 <dialog> Tag

The HTML5 dialog tag is a powerful tool that web developers can use to create dialog boxes or windows on a webpage. This tag, which is new in HTML5, allows for the creation of popup dialogs and modals, enhancing the interactivity of your website.

Syntax:

<dialog open> Contents... </dialog>

Attributes:

HTML attributes provide extra information about HTML elements and are defined within the element's opening tag to modify or specify their behavior, appearance, or interaction.

Example 1:  In this example, we will see how to use the HTML5 dialog tag with an example.

<!DOCTYPE html>
<html>

<body>
    <h1>&lt;dialog&gt; tag</h1>
    <dialog open>
        Welcome to GeeksforGeeks
    </dialog>
</body>

</html>

Output: 


Example 2:  In this example, we will see how to use the HTML5 dialog tag with image and button tag.

<!DOCTYPE html>
<html>

<body>
    <dialog open>
        <img src="path/to/image.jpg" alt="Preview Image">
        <button id="closeImagePreview">
            Close
        </button>
    </dialog>
</body>

</html>

Output: 

aas

Output

Supported Browsers: 

Article Tags :