The :open pseudo-class selects elements that support open and closed states — <details> and <select> among them — and matches them while they are open. Its inverse has no home yet: :closed is not specced. Until it is, :not(:open) does the job.

Given a <details> element, details:open can be styled with a light blue background and dark red text that applies only in the open state — in every browser but Safari at the time the source was written.

details:open {
  background: lightblue;
  color: darkred;
}

The closed state, meanwhile, is reachable through negation:

/* When details is _not_ open, but closed */
details:not(:open) {
  /* ... */
}

How :open got its name

The conversation began in May 2022, when Mason Freed raised the idea of a pseudo-class targeting elements in the top layer, such as popups. At the time :top-layer was also under consideration as a name. The OpenUI WC resolved to add a :top-layer pseudo-class applying at minimum to elements using the Popup API that are currently in the top layer, but intended it as general purpose: it should match any element in the top layer, including modal <dialog>, fullscreen elements, and ::backdrop pseudo-elements. That raised the question of whether the name should be :open or :top-layer. In August 2022 the CSSWG settled on :open, a name the source author preferred because “open” presumes something in the top layer.

The case against :closed

In September 2022, Freed asked whether a companion :closed pseudo-class should exist so that elements could be matched in their closed states the same way. Tab Atkins responded favorably, calling the definition of “openness” one that lines up with what most developers think “open” means and that HTML could connect to specific elements. He also raised the counterpart: :not(:open) can match anything, including things that don’t open or close at all. Agreement seemed broad at first.

It did not hold. In October 2022, Joey Arhar opened a new issue (#11039) on :closed because consensus had not actually formed. Luke Warlow’s objection: making :closed match things that can never be open feels odd, and would essentially make it :not(:open) — in which case, why have :closed at all? He drew a parallel to popovers: there is no :popover-closed because it is simply the inverse of :popover-open.

Where things stand

In November 2024, consensus settled on shipping :open alone and removing :closed for the time being. Both WHATWG and the CSSWG have indicated that the decision could change later.

A relevant note Bramus posted a month before the WHATWG decision: :read-only is defined as :not(:read-write), and that shipped. A negated definition is therefore not without precedent, even if it leaves the matching set wider than the attribute suggests.

Readability versus precision

Speaking for himself, the source author is fine with either :closed or :not(:open) so long as it works. He swapped :closed for :not(:open) in his ::checkmark and ::picker() examples, which is why those examples read as they do today. Pushed to choose, he would pick :closed: on a typical day it is easier to think in literal terms than in negated statements.

The trade-off is stated plainly on both sides — :closed reads directly but must define what “closed” means for elements that never open; :not(:open) is available now but matches too much. Those who want to follow or join the discussion can do so in the CSSWG drafts on GitHub.