HTML <dialog> Tag

The <dialog> tag is used to create a native dialog box, with which the user interacts, performing certain actions. For example, with this element, you can create pop-up messages or forms. By default, the dialog box is hidden from view, it is activated by the open attribute.


The <dialog> tag comes in pairs, the content is placed between the opening (<dialog>) and the closing (</dialog>) tags.

In order to display/hide the content, we need Javascript API.


<!DOCTYPE html>
    <title>Title of the document</title>
      dialog {
        width: 40%;
      <dialog id="DialogExample">
          Here is some text for example.
        <button id="hide">Close dialog text</button>
      <button id="show">Show dialog text</button>
    <script type="text/JavaScript">
      (function() {  
             var dialog = document.getElementById('DialogExample');  
             document.getElementById('show').onclick = function() {;  
           document.getElementById('hide').onclick = function() { dialog.close();  



Attribute Value Description
open open Indicates that the dialog box is active, and the user can interact with it.

The <dialog> tag also supports the Global Attributes and the Event Attributes.

Browser support

37+ 59+ 6+ 24+