Skip to content
Tutorials Center
My learning

Topics

CSS Reference ยท Pseudo-classes

The :popover-open pseudo-class

Reference for the CSS :popover-open pseudo-class: style popover elements only while they are showing, with a live popover example and browser support.

The :popover-open pseudo-class matches an element that has the HTML popover attribute and is currently showing. A popover is hidden by default (display: none from the browser); when a button with popovertarget or a script shows it, the element matches :popover-open.

Use it to style the open state, for example to set an entry animation or to change the button that opened the popover through :has().

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

Try it

A popover with an open-state style

Syntax

CSS
:popover-open { /* declarations */ }

No arguments; specificity (0,1,0).

Syntax and arguments

Part Description
[popover]:popover-open A popover that is showing.
[popover]:not(:popover-open) A popover that is hidden.
:has(:popover-open) An ancestor, such as the body, that contains an open popover.

Usage notes

  • Hidden popovers aren't rendered. The browser hides closed popovers with display: none, which is why entry animations need @starting-style and transition-behavior: allow-discrete.
  • Top layer. An open popover is displayed in the top layer, above everything else, with no z-index needed. Browsers give it default margin: auto, a border and padding, so reset what you don't want.
  • Light dismiss. Popovers set to auto close on Esc or an outside click, and only one auto popover is open at a time (except nested ones). popover="manual" stays open until you close it.
  • Not modal. Unlike :modal dialogs, the page behind stays usable.
  • Accessibility. The browser connects the button and the popover for assistive technology; keep a real <button> as the invoker.

Browser support

Supported in current versions of all major browsers; Baseline newly available since 2024, so older browsers lack it.