I want a “modal” boolean attribute on the dialog element

Submitted by Jiyoung Joung

This idea is currently being discussed.

I want a modal boolean attribute for the <dialog> element, so that dialogs can be declared as modal directly in HTML markup and opened via a single unified show() method rather than two separate methods.

Currently the <dialog> element has two JavaScript methods for opening it: show() (non-modal) and showModal() (modal). While both serve their purpose, this split makes the API inconsistent and requires authors to remember which method to call depending on the desired behavior. It also prevents authors from expressing modal intent declaratively in HTML.

A modal boolean attribute would address both issues:

Declarative HTML usage:

<dialog modal>
<!-- content -->
</dialog>

Browsers would open this dialog in modal mode as soon as it is displayed, without any JavaScript.

Unified JavaScript API:

const dialog = document.querySelector('dialog');
dialog.show({ modal: true });

A single show() method accepting an options object would unify both opening modes and make the intent explicit at the call site.

This aligns <dialog> with the pattern used by other HTML elements where boolean attributes encode default behavior declaratively, and it improves authoring ergonomics by reducing the cognitive overhead of choosing between two methods with nearly identical names but different semantics.

Tagged
HTML Dom
Votes
0
What are votes for and how are they tallied?