Skip to main content
Module 13 · Lesson 1 of 449/60 in the course~20 min
Module lessons (1/4)

<dialog>, ::backdrop & The Browser Top Layer

Lesson preview5 hands-on exercises readyModern HTML & CSS · Top Layer UI, Popovers & Modern Forms

Render true accessible dialogs above every stacking context using native top-layer semantics and high-contrast ::backdrop styling.

What you'll learn in this lesson

  • Understand how the browser Top Layer renders <dialog> elements above every z-index stacking context without parent clipping.
  • Structure an accessible native <dialog> with aria-labelledby, heading text, and a native close <form method="dialog">.
  • Style ::backdrop overlays and crisp keyboard :focus-visible outlines cleanly.

Overview

Traditional modal dialogs built out of nested <div> elements rely on fragile z-index: 9999 values. Whenever an ancestor card applies transform, opacity < 1, or overflow: hidden, the dialog gets trapped underneath nearby headers or sidebars.

Native <dialog> elements shown with showModal() (or inspected declaratively with open) live inside a separate browser layer called the Top Layer—painted on top of the entire document regardless of parent transforms or stacking contexts.

Sections covered in this lesson

  1. 1Escaping z-index Wars With the Top Layer
  2. 2Styling ::backdrop & Semantic Labels
Pro Lesson · Top Layer UI, Popovers & Modern Forms

Unlock "<dialog>, ::backdrop & The Browser Top Layer" and the full Modern HTML & CSS curriculum

Render true accessible dialogs above every stacking context using native top-layer semantics and high-contrast ::backdrop styling.

Unlock all 5 hands-on exercises in this lesson plus every advanced WebAssembly module with automated checks.

  • Instant access to all advanced modules in Modern HTML & CSS plus 17 more courses
  • Hands-on browser exercises with automated test suites and solutions
  • 14-day money-back guarantee processed via Paddle.com

14-day guarantee · Cancel anytimeModule 1, all 18 interactive games, and cheatsheets are always free.