This is an experimental technology
Because this technology's specification has not stabilized, check the compatibility table for usage in various browsers. Also note that the syntax and behavior of an experimental technology is subject to change in future versions of browsers as the specification changes.

The HTMLDialogElement interface provides methods to manipulate <dialog> elements. It inherits properties and methods from the HTMLElement interface.


Inherits properties from its parent, HTMLElement.
Is a Boolean reflecting the open HTML attribute, indicating that the dialog is available for interaction.
Is a DOMString that sets or returns the return value for the dialog.


Inherits methods from its parent, HTMLElement.

Name & Arguments Return Description
close() HTML5 void Closes the dialog. An optional DOMString may be passed as an argument, updating the returnValue of the the dialog.
show() HTML5 void Displays the dialog modelessly, i.e. still allowing interaction with content outside of the dialog.
showModal() HTML5 void Displays the dialog as a modal, over the top of any other dialogs that might be present. Interaction outside the dialog is blocked. User may press the "Escape" key to close the modal.


Example 1

<!-- Anchor point example -->
<dialog id="bronteDialog">
  <p>That was part of a poem by Emily Brontë!</p>

  <p>"Then art thou glad to seek repose?<br>
  Art glad to leave the sea,<br>
  And <strong id="anchor">anchor</strong> all thy weary woes<br>
  In calm Eternity?"</p>

  <button id="showDialogButton">Show dialog</button>

  (function() {
    var showDialogButton = document.getElementById('showDialogButton');

    // 'Show dialog' button opens dialog
    showDialogButton.addEventListener('click', function() {
      var bronteDialog = document.getElementById('bronteDialog');;


Example 2

<!-- Simple pop-up dialog box, containing a form -->
<dialog id="favDialog">
  <form method="dialog">
      <p><label for="favAnimal">Favorite animal:</label>
      <select id="favAnimal" name="favAnimal">
        <option>Brine shrimp</option>
        <option>Red panda</option>
        <option>Spider monkey</option>
      <button id="cancel" type="reset">Cancel</button>
      <button type="submit">Confirm</button>

  <button id="updateDetails">Update details</button>

  (function() {
    var updateButton = document.getElementById('updateDetails');
    var cancelButton = document.getElementById('cancel');

    // Update button opens a modal dialog
    updateButton.addEventListener('click', function() {

    // Form cancel button closes the dialog box
    cancelButton.addEventListener('click', function() {



Specification Status Comment
WHATWG HTML Living Standard
The definition of '<dialog>' in that specification.
Living Standard  
The definition of '<dialog>' in that specification.

Browser compatibility

Feature Chrome Firefox (Gecko) Internet Explorer Opera Safari
Basic support 37 No support bug 840640 No support 24 No support
Feature Android Firefox Mobile (Gecko) IE Mobile Opera Mobile Safari Mobile
Basic support No support No support No support No support No support

See also

  • The HTML element implementing this interface: <dialog>.

Document Tags and Contributors

 Contributors to this page: ntim, slimsag, fscholz, MHasan, dhodder
 Last updated by: ntim,