Favorites

CSS overlay Property

overlay
CSS PropertyThis property is supported in some modern browsers, but not all.
Updated 22nd November 2026

The overlay property keeps an element in the top layer while it animates out, used with transition-behavior: allow-discrete. Only browsers set its value.

☕
Enjoying this site?

Help keep it running with a small coffee donation. Every bit of support is appreciated!

Buy us a coffee

Description

The overlay property reports whether an element is in the browser's top layer, the special layer above the rest of the page used by modal dialogs, popovers and fullscreen elements. Its value is auto while the element is in the top layer and none otherwise.

Authors cannot set it to put an element into the top layer; that only happens through APIs such as showModal() or showPopover(). Its purpose is animation: listing overlay in a transition with transition-behavior allow-discrete keeps a closing dialog or popover in the top layer until its exit transition has finished, so it does not drop behind other content while fading out.

[popover] {
  transition: opacity 0.3s, overlay 0.3s allow-discrete, display 0.3s allow-discrete;
}

Definition

Initial value
none
Applies to
all elements
Inherited
no
Computed value
as specified
Animatable
discrete
JavaScript syntax
object.style.overlay

Syntax

overlay: none | auto;

Values

  • noneThe element is not in the top layer.
  • autoThe element is in the top layer. This value cannot be set by authors.
  • initialSets the property to its initial value.
  • inheritTakes the computed value of the parent element.

Example

<button popovertarget="pop">Toggle popover</button>
<div id="pop" popover>I stay in the top layer while fading out.</div>
[popover] {
  padding: 20px 28px;
  border: none;
  border-radius: 10px;
  background: #4361ee;
  color: #fff;
  font-family: system-ui, sans-serif;
  opacity: 0;
  transition: opacity 0.4s, overlay 0.4s allow-discrete, display 0.4s allow-discrete;
}

[popover]:popover-open {
  opacity: 1;
}

@starting-style {
  [popover]:popover-open { opacity: 0; }
}

button {
  font: 16px system-ui, sans-serif;
  padding: 8px 16px;
}
Open in editor

Browser Support

The following information will show you the current browser support for the CSS overlay property. Hover over a browser icon to see the version that first introduced support for this CSS property.

This property is supported in some modern browsers, but not all.

Desktop

Chrome
Edge
Firefox
Opera
Safari

Tablets & Mobile

Chrome Android
Firefox Android
Opera Android
Safari iOS
Samsung Internet
Android WebView
-
Supported Unknown Not supported
☕
Enjoying this site?

Help keep it running with a small coffee donation. Every bit of support is appreciated!

Buy us a coffee