# ::backdrop

> The `::backdrop` CSS pseudo-element styles the layer behind an element in the top layer, such as a modal dialog, a popover or a fullscreen element.

## How do I style the background behind a modal dialog?

The pseudo-element that represents the backdrop behind a modal or fullscreen element. It allows styling the background that appears behind the content, often used to create dimming or blurring effects.

- Topic: Pseudo Elements
- Type: pseudo-element
- Browser support: Chrome 37+, Chrome Android 37+, Edge 79+, Firefox 47+, Firefox Android 47+, Safari 15.4+, Safari iOS 15.4+

## Example

Wrong:

```css
.overlay {
  position: fixed;
  inset: 0;
  background: rgb(0 0 0 / 50%);
}
```

Right:

```css
dialog::backdrop {
  background: rgb(0 0 0 / 50%);
  backdrop-filter: blur(4px);
}
```

`::backdrop` sits right under the modal in the top layer, so no extra overlay element or `z-index` is needed.

## Common mistakes

- `::backdrop` doesn't show because the dialog was opened with `show()`.
- Adding a separate overlay `<div>` that stays below the top layer anyway.

## Key points

- The dialog opens with `showModal()`, or the element is a shown popover, so it is in the top layer and gets `::backdrop`.
- The backdrop isn't faked with a full-screen `<div>` overlay.
- Backdrop clicks are handled on the `<dialog>` element, since `::backdrop` has no event listeners of its own.

## Interview questions

### Why is my ::backdrop not showing?

The element is not in the top layer. Open the dialog with `showModal()`, the popover with `showPopover()`, or the element with `requestFullscreen()`.

### Can I animate ::backdrop?

Yes. Transition its `background-color` or `opacity` and set the start values in `@starting-style` so it fades in on open.

## Related cards

- [:modal](https://wonderium.dev/css/modal.md)
- [`<dialog>`](https://wonderium.dev/html/dialog.md)
- [\[popover\]](https://wonderium.dev/html/popover.md)
- [backdrop-filter](https://wonderium.dev/css/backdrop-filter.md)
- [@starting-style](https://wonderium.dev/css/starting-style.md)

---

- Level: [CSS](https://wonderium.dev/css.md)
- HTML version: https://wonderium.dev/css/backdrop
- Last updated: 2026-11-25
