HTMLDialogElement: close event

The close event is fired on an HTMLDialogElement object when the dialog it represents has been closed.

Bubbles No
Cancelable No
Interface Event
Event handler property onclose


Live example


<dialog class="example-dialog">
    <button class="close" type="reset">Close</button>

<button class="open-dialog">Open dialog</button>

<div class="result"></div>


const result = document.querySelector('.result');

const dialog = document.querySelector('.example-dialog');
dialog.addEventListener('close', (event) => {
    result.textContent = 'dialog was closed';

const openDialog = document.querySelector('.open-dialog');
openDialog.addEventListener('click', () => {
  if (typeof dialog.showModal === 'function') {
      result.textContent = '';
  } else {
      result.textContent = 'The dialog API is not supported by this browser';

const closeButton = document.querySelector('.close');
closeButton.addEventListener('click', () => {



Specification Status
HTML Living Standard
The definition of 'close' in that specification.
Living Standard

Browser compatibility

Update compatibility data on GitHub
ChromeEdgeFirefoxInternet ExplorerOperaSafariAndroid webviewChrome for AndroidFirefox for AndroidOpera for AndroidSafari on iOSSamsung Internet
close eventChrome Full support YesEdge No support NoFirefox No support NoIE No support NoOpera ? Safari No support NoWebView Android No support NoChrome Android No support NoFirefox Android No support NoOpera Android No support NoSafari iOS No support NoSamsung Internet Android No support No


Full support  
Full support
No support  
No support
Compatibility unknown  
Compatibility unknown

See also

Document Tags and Contributors

Contributors to this page: wbamberg, mdnwebdocs-bot, Sheppy, mfluehr, erikadoyle, cvrebert, teoli
Last updated by: wbamberg,