CSS can now tell when a <select> is showing its drop-down or a date input has its picker up, and JavaScript can finally ask a popover "who opened you?". Both arrived in Safari 26.5 in May 2026, which made :open and ToggleEvent.source Baseline Newly available on the same day. Neither is flashy on its own, but together they remove two little hacks I've written more times than I'd like.
One pseudo-class for "it's open"
Until now, styling the open state depended on the element. For <details> and <dialog> you used the attribute selector [open]. For a <select> with its list showing or an <input type="date"> with its calendar visible there was nothing at all: those states lived inside the browser and CSS couldn't see them.
The HTML spec now defines :open as matching four things:
<details>elements that have anopenattribute,<dialog>elements that have anopenattribute,<select>elements that are a drop-down box and whose drop-down is open,<input>elements that support a picker and whose picker is open (color, date and friends).
So the same selector covers all of them:
details:open { border-color: var(--orange); }
details:open > summary::before { rotate: 90deg; }
/* select with its list showing, input with its picker up */
:is(select, input):open {
border-color: var(--orange);
box-shadow: 0 0 0 4px rgb(255 82 0 / .2);
}
The part I find more interesting is combining it with :has(). In the demo above, the "What CSS sees" board on the right has no JavaScript at all. Every light is a rule like this one:
.lab:has(select:open) .led-select .dot { background: var(--teal); }
.lab:has(dialog:open) .led-dialog .dot { background: var(--teal); }
That's a parent reacting to a child's open state, which is exactly what you want for things like "dim the rest of the form while a picker is open" or "highlight the field's label while its drop-down is showing". MDN's own example does the second one with label:has(select:open).
Two details worth knowing. First, open and closed are semantic states, not visibility: MDN points out that a <details> that is expanded but hidden with visibility: hidden still matches :open. Second, the WebKit announcement notes that for <dialog> it matches whether you opened it with showModal() or show(). The demo uses show() on purpose, so the dialog stays inline and you can see its light turn on.
Popovers don't use :open
This is the gotcha: elements with the popover attribute never match :open. MDN is explicit that popovers have their own states, and the one you want is :popover-open. The last row of the board, the dashed [popover]:open one, is there to prove it: open the popover and it stays off while :popover-open lights up.
ToggleEvent.source: which button was it?
Popovers fire a toggle event when they open or close. What was missing was the reason. If three buttons can open the same popover (a toolbar, a card, a keyboard shortcut), you used to attach a click handler to each one and stash the "last clicked" button in a variable before the popover opened.
Now the event carries it. event.source is the element that triggered the toggle, or null if no control element did:
pop.addEventListener('toggle', (event) => {
if (event.newState === 'open') {
console.log('Opened by:', event.source); // <button id="btn-card"> or null
}
});
According to MDN, source is set when a <button> controls the popover with commandfor (plus command) or with popovertarget; an <input type="button"> only gets there with popovertarget. If you open it from script with a method like togglePopover(), source is null.
In the demo, "Toolbar" and "Card button" use commandfor="pop" command="toggle-popover", and the popover writes back which one it was and makes that button glow. "From script" calls pop.togglePopover() from a click listener, and the log shows null, even though a button was technically pressed: what counts is the invoker relationship, not the click. Close it with Escape or by clicking outside and you'll also see null, while the Close button inside the popover reports itself as the source.
Browser support and gotchas
Both features became Baseline Newly available on May 11, 2026, with Safari 26.5. Chrome and Firefox had them earlier: :open since Chrome 133 and Firefox 136, ToggleEvent.source since Chrome 140 and Firefox 145. Newly available means older browsers still in use won't have them, so:
- Feature-detect
:openwith@supports selector(:open). Inside a rule, don't mix:openinto a selector list with selectors you need: an unknown pseudo-class invalidates the whole list, so keep separate rules. The demo falls back todetails[open]anddialog[open], which works everywhere, and warns that select and input can't be detected. - Feature-detect
sourcewith'source' in ToggleEvent.prototype. The demo's plan B remembers the last trigger clicked, the old way. commandforitself is newer thanpopovertarget(Invoker Commands became Baseline in December 2025). If you need older browsers,popovertargetalso setssource.- Native pickers are awkward to test. Running the demo headless with Playwright, the color input matched
:openin Chromium, Firefox and WebKit, but only Chromium actually opened the<select>drop-down, so that light I could only check there. Details, dialog and popover behaved the same in all three.
What to keep an eye on
The customizable <select> work leans on :open for its picker styles, and MDN already pairs select:open with ::picker(select). As that lands in more engines, :open becomes the hook for animating pickers in and out. On the JavaScript side, source turns "which trigger opened this menu" into a property instead of bookkeeping, which is the kind of thing that quietly removes bugs.