TLDR Web Dev · ARTICLES & TUTORIALS

A COUPLE CSS TRICKS FOR HTML DIALOG ELEMENTS

cassidoo.co2 min read

Summary from the TLDR Web Dev newsletter

This article presents two CSS tricks for enhancing HTML `dialog` elements. The first trick uses the `::backdrop` pseudo-element to blur the background behind the dialog for a subtle visual effect. The second trick disables page scrolling while a dialog is open using the `body:has(dialog[open])` selector. This prevents the underlying page content from shifting during interaction with the dialog.