For years, styling the open state of a disclosure widget meant reaching for an attribute selector. details[open] worked because the HTML parser and the browser toggle an open attribute on the element. It was reliable for details and dialog, but it said nothing about a select with its list showing or a color input with its picker on screen. For those, developers added a class from JavaScript on focus and removed it on blur, and the class was often wrong the moment the user pressed Escape.

The :open pseudo-class gives all of these a single selector that the browser maintains itself. MDN lists it as Baseline Newly available as of May 2026, and web.dev’s May 2026 platform update attributes the milestone to Safari 26.5, with Chrome and Edge 133 and Firefox 136 already in place.

What :open Matches

According to MDN, :open represents an element that has both open and closed states, when it is in the open state. In practice that covers three groups:

  • details elements that have the open attribute.
  • dialog elements that have the open attribute.
  • select elements while their dropdown is displayed, and input elements with a picker, such as color or date, while the picker is displayed.
details:open > summary {
  background: #eef4ff;
}

select:open {
  outline: 2px solid #2b6cb0;
}

label:has(select:open) {
  background: #fff8e1;
}

The last rule combines :open with :has(), a pattern MDN demonstrates: style the label that wraps a select while the select’s list is showing. Neither the label nor the select needs a script to report that state.

Why It Is Better Than details[open]

For details and dialog, :open is mostly a readability gain. The selector says what you mean, and it works the same way in a style rule that targets several element types at once:

:is(details, dialog, select):open {
  border-color: #2b6cb0;
}

The real gain is with form controls. A select has no attribute that records “the list is showing”, so before :open there was no declarative way to know. The pseudo-class closes that gap for native dropdowns and picker inputs, which lets a design system draw a focus-ring variant, rotate a chevron, or tint a wrapper while the native list is open.

The Semantic State Catch

The most important behavior to understand is that :open tracks semantic state, not visual state. MDN notes that a details element hidden with visibility: hidden still matches :open as long as it has the open attribute. The browser is reporting what the element is, not whether the user can see it.

This matters in a few situations:

  • A details inside a collapsed parent can match :open while being invisible. If you animate or decorate based on :open, scope the rule to a visible ancestor.
  • A dialog shown with show() or showModal() matches because both methods set the open attribute. A dialog closed with close() does not match.
  • Popovers are a separate case. An element shown through the Popover API matches :popover-open, not :open, so a menu built on popovers needs the other selector.

Animating Open and Closed

An open state selector is most useful when paired with transitions. Elements such as dialog are removed from rendering when closed, so a naive transition has nothing to animate from. The @starting-style rule and transition-behavior: allow-discrete let you define the entry state, and :open is a clean hook for the end state.

dialog {
  opacity: 0;
  transition: opacity 0.2s, display 0.2s allow-discrete;
}

dialog:open {
  opacity: 1;
}

@starting-style {
  dialog:open {
    opacity: 0;
  }
}

Check the compatibility tables for @starting-style and discrete transitions separately, since their support timeline is not the same as :open.

Accessibility Considerations

The pseudo-class changes appearance only. It does not alter the accessibility tree, so a visual change must never be the only signal of state. Native details and dialog already expose their expanded and modal states to assistive technology, which is a strong reason to use them instead of custom div widgets. If you restyle summary, keep a visible focus indicator and make sure the open and closed states differ by more than color. A rotated marker or changed icon works; a slightly different background does not meet that bar for many users.

For select elements, the native control is already announced correctly. Styling select:open is decoration, so keep contrast between the control and its surroundings at the WCAG 2.2 non-text contrast level of 3:1.

Fallbacks

Because the feature became available in all three engines only recently, older browsers will ignore a rule whose selector they do not understand. An unrecognized selector in a list invalidates the whole rule, so do not group :open with other selectors you need everywhere:

details[open] > summary {
  background: #eef4ff;
}

details:open > summary {
  background: #eef4ff;
}

Duplicating the rule is the safest path for details and dialog while your analytics still show older Safari. For select and picker inputs, there was never a declarative fallback, so the enhancement simply will not appear there.

Testing the States

Test each state by hand before shipping. Open and close a details with the keyboard using Enter and Space on the summary, press Escape on a modal dialog, and open a select with the mouse and with Alt plus the down arrow. Confirm that the styling appears and clears each time, including when focus moves away without a selection being made. Because the browser owns the state, these checks are quick, and they catch the stale-class bugs the old approach produced.

Practical Takeaway

Replace class toggles that mirror open state with :open where the element is a details, dialog, select, or picker input. Keep [open] rules alongside them for details and dialog until older Safari drops out of your support range, remember that the match is semantic and survives visibility: hidden, and use :popover-open for anything built on the Popover API. The reward is less script, fewer stale classes, and styling that follows the browser’s own idea of what is open.