Educational guide to open state selectors
Three syntaxes, three different questions
Connect persistent attributes and transient states to the native element that actually defines them.
Mental model
Choose the selector according to the source of state you need to observe.
[open]Inspect the HTML
Ask whether the open attribute is present; this does not generalize to every element that opens an interface.
:openInspect semantic state
Ask whether an element that can open or close is currently open.
:popover-openInspect popover visibility
Ask whether an element with popover is currently in the showing state.
open attribute
Observe the HTML-reflected state of details and dialog.
[open]
Elements whose HTML includes the open attribute.
Specificity(0, 1, 0)
[open]
Behavior
- For details and dialog, the open property reflects this boolean attribute.
- It may remain present until interaction or an API closes the element.
Examples
[open]Matches: <details open>Visible content</details>
<details>Hidden content</details>dialog[open]Matches: <dialog open>Non-modal dialog</dialog>
<div popover>Popover</div>Common mistakes
- It does not select a select whose picker is open.
- Do not replace it with [popover], which declares a different capability.
Support and compatibility
Attribute selectors are widely available.
:open state
Group details, dialog, select, and picker-supporting inputs under one semantic pseudo-class.
:open
Elements with an open/closed state that are currently open.
Specificity(0, 1, 0)
:open
Behavior
- It applies to details, dialog, select, and picker-supporting inputs while their UI is open.
- It describes state even though it normally agrees with open presence on details and dialog.
Examples
:openMatches: <details open>Visible content</details>
<details>Hidden content</details>select:openMatches: <select>
<option>One</option>
<option>Two</option>
</select>input[type="color"]:openMatches: <input type="color" value="#f97316">Common mistakes
- It does not apply to a popover merely because it is showing.
- The select and input states are transient and depend on opening their native UI.
Support and compatibility
:open is Baseline Newly Available since May 2026; keep support detection.
Showing popover
Distinguish declaring a popover from showing it in the top layer.
:popover-open
Popover elements that are currently showing.
Specificity(0, 1, 0)
:popover-open
Behavior
- The popovertarget button activates the state without JavaScript.
- When hidden, the element keeps popover but stops matching.
Examples
[popover]:popover-open<button popovertarget="help">Help</button>
Matches: <div id="help" popover>Popover content</div>Common mistakes
- [popover] also selects hidden popovers.
- It is not a variant of :open and does not depend on the open attribute.
Support and compatibility
The state belongs to the Popover API, which is Baseline Newly Available.