# :open

> The `:open` CSS pseudo-class selects elements that have open and closed states while they are open.

## What does the :open pseudo-class select in CSS?

The pseudo-class that matches elements such as `<details>`, `<dialog>`, `<select>` and `<input>` with a picker while they are in the open state. Allows styling the open state without relying on attribute selectors like `[open]`.

- Topic: Pseudo Classes
- Type: pseudo-class
- Browser support: Chrome 133+, Chrome Android 133+, Edge 133+, Firefox 136+, Firefox Android 136+, Safari 26.5+, Safari iOS 26.5+

## Example

Wrong:

```css
details.is-open summary {
  font-weight: bold;
}
```

Right:

```css
details:is([open], :open) summary {
  font-weight: bold;
}
```

`:is()` forgives an unknown `:open`, so `[open]` still works as a fallback and no JavaScript class is needed.

## Common mistakes

- Expecting `:open` to match popovers, which use `:popover-open`.

## Key points

- Open states are styled with `:open` or `[open]` instead of a class toggled by JavaScript.
- A `[open]` fallback exists for `<details>` and `<dialog>` where `:open` is unsupported.

## Interview questions

### What is the difference between :open and [open]?

`[open]` checks the HTML attribute, which only `<details>` and `<dialog>` have. `:open` also covers `<select>` and inputs with a picker, which have no such attribute.

### Does :open match a dialog opened with show()?

Yes. Any open `<dialog>` matches `:open`, whether it was opened with `show()` or `showModal()`; only modal ones also match `:modal`.

## Related cards

- [`<details>`](https://wonderium.dev/html/details.md)
- [`<dialog>`](https://wonderium.dev/html/dialog.md)
- [:popover-open](https://wonderium.dev/css/popover-open.md)
- [::details-content](https://wonderium.dev/css/details-content.md)
- [:modal](https://wonderium.dev/css/modal.md)

---

- Level: [CSS](https://wonderium.dev/css.md)
- HTML version: https://wonderium.dev/css/open
- Last updated: 2026-11-25
