<dialog> Element Playground

Pak RT’s question in a real <dialog>: open it with showModal() or show(), then the browser answers where focus goes, whether the page behind still takes…

Why it matters

Confirmations, sign-in forms, warnings: modals are everywhere and most often wrong for accessibility. showModal() handles the top layer, an inert background, focus going in and back, Esc and ::backdrop. A method="dialog" form hands its answer back through returnValue. Less code, fewer bugs.

The key idea

showModal() moves the dialog to the top layer and switches the rest off

Common mistakes

Try it in this playground