CKTIS / CSS
:popover-open — selecting a showing popover
The :popover-open pseudo-class selects an element in its popover-showing state. It distinguishes that state from merely having the popover attribute, allowing styles to apply only while the popover is open.
Version: CSS modules; structured CSSWG indexes reconciled with pinned MDN BCD; Chromium 152 scope gate, per-example verification still required
Syntax
:popover-openThe :popover-open pseudo-class represents an element that supports popover-hidden and popover-showing states and is currently in the latter state. In HTML, it matches an element whose popover attribute is not in the No Popover state and whose internal popover visibility state is showing.
The [popover] selector checks for the attribute, including when the popover is closed. In contrast, :popover-open tracks its state. The selector itself opens nothing: use an HTML mechanism such as a button with popovertarget, or the showPopover() method; hidePopover() closes it. Changing display alone does not replace changing the popover state.
Do not confuse :popover-open with :open. The latter concerns element-specific open states, such as that of a details element. Popover state is independent of such an open state.
The example checks matching before showPopover(), after it, and after hidePopover(). The expected results are false, true, false, in that order. The CSS rule applies only in the middle state; because the script immediately closes the popover, its appearance need not become visible on screen. The example requires local verification in the target browser.
Examples
<!doctype html>
<html lang="en">
<meta charset="utf-8">
<title>:popover-open demo</title>
<style>
#panel:popover-open {
border: 3px solid navy;
background: lightyellow;
}
</style>
<div id="panel" popover="manual">Popover content</div>
<pre id="result"></pre>
<script>
const panel = document.getElementById('panel');
const states = [];
states.push(panel.matches(':popover-open'));
panel.showPopover();
states.push(panel.matches(':popover-open'));
panel.hidePopover();
states.push(panel.matches(':popover-open'));
document.getElementById('result').textContent = states.join('\n');
</script>
</html>Result
false true false
The displayed code and declared result were verified in an isolated environment using the method recorded in the verification evidence for this exact version.