v145 · light dismiss

What closedby resolves to

An enumerated attribute with two different missing-value defaults, chosen by whether the dialog is modal. That is unusual enough to be worth measuring rather than remembering — so every combination below is set on a real dialog and read back.

Every value, in every state

The attribute set on a real dialog, then read through the IDL property
attribute closed show() showModal() what it means
Measuring…

Every cell is a real <dialog> that was opened, read and closed again while you waited — off-screen, and modal dialogs included. The measurement takes a moment because opening a modal dialog is a real operation, not a property read.

Open one and see

Three dialogs, identical except for their closedby. Open each and try clicking the backdrop, then Escape.

Nothing opened yet.

closedby="any"

Click outside this box, or press Escape. Both close it.

closedby="closerequest"

Escape closes this. Clicking outside does not — try it first, then press Escape.

closedby="none"

Neither Escape nor a click outside closes this one. The button is the only way out, which is the point of asking for it.

A dialog with closedby="none" is a promise you have to keep: if the only exit is a control inside, that control must always be reachable and must always work. This one closes on the button and on nothing else, deliberately.

The popover values, for comparison

The popover attribute, whose invalid-value default goes the other way
attributeresolves tonote

The two attributes disagree about what a typo should mean, and both are defensible: a mistyped popover becomes manual, which stays open until told otherwise, and a mistyped closedby becomes none. Both choose the option that does not vanish unexpectedly — a dialog that a typo turned into "closes on any click" would lose the user's work.

see also