IT lexicon › Web › <dialog> element

<dialog> element

Web På svenska → Updated: 2026-05-30

A built-in HTML element for modals and dialogs. <dialog> with showModal() gives you for free what previously required a lot of JavaScript: a backdrop overlay, a focus trap, Esc closing, and correct accessibility — all per the standard.

What you avoid building yourself: a true modal requires that focus is trapped inside (Tab shouldn't take you out), that the background is blocked (::backdrop), that Esc closes it, that focus returns to where it was, and the right ARIA roles for screen readers — historically a common source of buggy, inaccessible home-builds. <dialog>.showModal() gives all of this built-in and correct; show() gives a non-modal variant. It's rendered in the browser's "top layer" (above everything else, independent of z-index and overflow). Combined well with the Popover API (for non-modal popups) and anchor positioning. Widely supported since 2022. A clear example of the platform taking back ground from libraries. Related to popover and focus trap.

← Back to the lexicon