CSS Portal

:popover-open CSS Pseudo Class

If this site has been useful, we’d love your support! Consider buying us a coffee to keep things going strong!

Description

The :popover-open pseudo-class targets an element that is currently displayed as an open popover, meaning it has been activated via the Popover API and is visible to the user. This pseudo-class is part of the modern HTML Popover feature and allows you to style a popover only while it is open, without needing JavaScript or additional state classes.

It applies to elements that use the popover attribute (such as popover, popover="auto", or popover="manual"). When the popover is shown - typically triggered by a button using popovertarget - the element matches :popover-open until it is closed.

What :popover-open Does

  • Targets only visible popovers
  • Automatically updates when the popover opens or closes
  • Removes the need for JavaScript-based state tracking
  • Works seamlessly with native browser behavior

This makes it ideal for styling transitions, animations, or visual emphasis while the popover is active.

Basic Example

<button popovertarget="infoBox">Show Info</button>

<div id="infoBox" popover>
  This is a popover message.
</div>
:popover-open {
  background-color: #f0f8ff;
  border: 2px solid #4a90e2;
  padding: 1rem;
}

In this example, the popover only receives the styling while it is open.

Targeting a Specific Popover

You can combine the selector with an element type or ID:

div:popover-open {
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.2);
}

This ensures the styles only apply to <div> elements that are currently open as popovers.

Transitions and Animations

You can use transitions for smoother visual effects:

[popover] {
  opacity: 0;
  transform: scale(0.95);
  transition: opacity 0.2s ease, transform 0.2s ease;
}

:popover-open {
  opacity: 1;
  transform: scale(1);
}

This creates a subtle zoom-and-fade animation when the popover opens.

Commonly Used With

Accessibility Notes

  • Popovers automatically manage focus when opened.
  • Clicking outside the popover or pressing Esc closes it (for popover="auto").
  • Screen readers correctly interpret popover state changes when implemented natively.

Syntax

:popover-open {
  /* ... */
}

Example

<button popovertarget="my-popover">Open Notification</button>

<div id="my-popover" popover>
<h3>Stay Tuned!</h3>
<p>This is a native HTML popover styled with the :popover-open pseudo-class.</p>
</div>
/* Default state of the popover */
[popover] {
padding: 1.5rem;
border: 2px solid #ccc;
border-radius: 8px;
background-color: #f9f9f9;
transition: all 0.4s ease-in-out;

/* Start slightly transparent and shifted */
opacity: 0;
transform: translateY(10px);
}

/* State when the popover is visible */
[popover]:popover-open {
opacity: 1;
transform: translateY(0);
border-color: #007bff;
box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
}

/* Optional: Styling the backdrop (the area behind the popover) */
[popover]::backdrop {
background-color: rgba(0, 0, 0, 0.5);
backdrop-filter: blur(2px);
}

Browser Support

The following information will show you the current browser support for the CSS :popover-open pseudo class. Hover over a browser icon to see the version that first introduced support for this CSS psuedo class.

This psuedo class is supported by all modern browsers.
Desktop
Chrome
Edge
Firefox
Opera
Safari
Tablets & Mobile
Chrome Android
Firefox Android
Opera Android
Safari iOS
Samsung Internet
Android WebView
-

Last updated by CSSPortal on: 31st December 2025

If this site has been useful, we’d love your support! Consider buying us a coffee to keep things going strong!