HTMLDialogElement: closedBy property

Limited availability

This feature is not Baseline because it does not work in some of the most widely-used browsers.

The closedBy property of the HTMLDialogElement interface indicates the types of user actions that can be used to close the associated <dialog> element. It sets or returns the dialog's closedby attribute value.

Value

A string; possible values are:

any

The dialog can be dismissed with a light dismiss user action, a platform-specific user action, or a developer-specified mechanism.

closerequest

The dialog can be dismissed with a platform-specific user action or a developer-specified mechanism.

none

The dialog can only be dismissed with a developer-specified mechanism.

Default behavior

If the closedby attribute is absent or invalid, it falls back to the Auto state. In the Auto state:

  • when the <dialog> is opened with showModal(), it behaves as if: closedby="closerequest"
  • when the <dialog> is opened by any other means, it behaves as if: closedby="none"

Examples

Basic closedBy usage

html
<dialog closedby="any">
  <p>
    Closable using the <kbd>Esc</kbd> key, or by clicking outside the dialog
    ("light dismiss").
  </p>
</dialog>
js
const dialog = document.querySelector("dialog");
dialog.showModal();
log(`closedBy: ${dialog.closedBy}`);

Result

Specifications

Specification
HTML
# dom-dialog-closedby

Browser compatibility

desktop mobile
Chrome
Edge
Firefox
Opera
Safari
Chrome Android
Firefox for Android
Opera Android
Safari on iOS
Samsung Internet
WebView Android
WebView on iOS
closedBy
Chrome – Full support
Chrome 134 (Release date: 2025-03-04)
footnote Full support
Edge – Full support
Edge 134 (Release date: 2025-03-06)
footnote Full support
Firefox – Full support
Firefox 141 (Release date: 2025-07-22)
footnote Full support
Opera – Full support
Opera 119 (Release date: 2025-05-13)
footnote Full support
Safari – No support
Safari
footnote
footnote See bug 284592
Chrome Android – Full support
Chrome Android 134 (Release date: 2025-03-04)
footnote Full support
Firefox for Android – Full support
Firefox for Android 141 (Release date: 2025-07-22)
footnote Full support
Opera Android – Full support
Opera Android 88 (Release date: 2025-03-19)
footnote Full support
Safari on iOS – No support
Safari on iOS
footnote
footnote See bug 284592
Samsung Internet – Full support
Samsung Internet 29 (Release date: 2025-10-25)
footnote Full support
WebView Android – Full support
WebView Android 134 (Release date: 2025-03-04)
footnote Full support
WebView on iOS – No support
WebView on iOS
footnote
footnote See bug 284592

Legend

Tip: you can click/tap on a cell for more information.

Full support
Full support
No support
No support
See implementation notes.

See also