Re: [csswg-drafts] [selectors] Add pseudo-classes for `<select>` being a drop-down box vs a list box (#7422)

The CSS Working Group just discussed ``[selectors] Add pseudo-classes for `<select>` being a drop-down box vs a list box``.

<details><summary>The full IRC log of that discussion</summary>
&lt;masonf> jarhar: There is an existing pseudo class for this in Chrome, and it'd be good to make that accessible to the web.<br>
&lt;Lwarlow> Q+<br>
&lt;masonf> jarhar: This will be helpful for the next issue - defining styles for dropdown vs listbox<br>
&lt;masonf> jarhar: Lea brought up that this means it won't be CSS-controllable to switch between listbox and dropdown. It'd be circular.<br>
&lt;masonf> jarhar: I don't think it should be controllable via CSS, we should just expose the thing we already have.<br>
&lt;masonf> jarhar: Two alternatives I saw: a has-picker() with the element, or select:has-picker<br>
&lt;astearns> ack Lwarlow<br>
&lt;masonf> jarhar correct my naming please<br>
&lt;masonf> lwarlow: could just be :has-picker, because people will put the element in the selector anyway<br>
&lt;masonf> lwarlow: the compat problem here is different from the appearance:base problem<br>
&lt;lea> Yes, I think `select:has-picker(select)` looks very weird from an author pov<br>
&lt;lea> q?<br>
&lt;masonf> lwarlow: with this pseudo class, it's less important. It'd be nice to just use select:has-picker<br>
&lt;masonf> lwarlow: perhaps you could do this in the future via CSS, if you have a rule that applies when the element renders<br>
&lt;masonf> astearns: whatever method we use to switch, you're saying we could make the pseudo only apply when it renders?<br>
&lt;masonf> lwarlow: maybe it only switches until the element renders, and then locks in until it stops rendering, to avoid circularity.<br>
&lt;masonf> lwarlow: I don't like CSS for this anyway, but I'm saying this doesn't block it if we really want to in the future<br>
&lt;masonf> lwarlow: appearance:base doesn't allow you to switch while the picker is open<br>
&lt;lea> q+<br>
&lt;masonf> lwarlow: having the switch in HTML makes sense, the size attribute makes sense<br>
&lt;masonf> lwarlow: I like the :has-picker because it matches<br>
&lt;astearns> ack lea<br>
&lt;masonf> lea: I'd support making this non-functional pseudo class<br>
&lt;masonf> lea: seems weird to duplicate the element type<br>
&lt;masonf> lea: very little precedent for selectors like this. Others are quite different.<br>
&lt;masonf> lea: if this only works for select, we need something to not break compat. Can't it just work for all pickers?<br>
&lt;Lwarlow> Q+<br>
&lt;masonf> lea: there is already showpicker. Perhaps we can just make it work?<br>
&lt;astearns> ack Lwarlow<br>
&lt;masonf> lwarlow: showpicker is designed so that it doesn't reveal whether there's a picker<br>
&lt;masonf> lwarlow: it also doesn't fully work in the web. E.g. ios webkit - only works for color picker. Or something else. But not all.<br>
&lt;lea> q+<br>
&lt;masonf> lwarlow: key reason is that detecting whether the picker opened is tough. I've implemented it but can't write tests.<br>
&lt;masonf> lwarlow: :has-picker would have the same behavior/problem<br>
&lt;masonf> lwarlow: it can work for base pickers - popovers are easy. But auto appearance pickers are tough<br>
&lt;masonf> lwarlow: also a question about whether we want to expose that. If authors depend on needing a picker, it causes issues.<br>
&lt;masonf> lwarlow: but select is different because both modes are specified and expected to exist<br>
&lt;astearns> ack lea<br>
&lt;masonf> lea: stepping back, do we need a pseudo class at all?<br>
&lt;masonf> lea: you can detect with attributes, and this is just making it easy. Maybe defer?<br>
&lt;una> q+<br>
&lt;masonf> lea: all proposed solutions have problems. If single :has-picker, I'd expect it to work everywhere. Requiring an argument is weird. It could be :drop-down?<br>
&lt;masonf> lea: if it doesn't work for appearance:auto, that would also be surprising.<br>
&lt;astearns> +1 to concern about this only work with appearance: base<br>
&lt;masonf> lea: having css properties affect pseudo class matching is circular<br>
&lt;astearns> ack una<br>
&lt;Lwarlow> Q+<br>
&lt;masonf> una: It's a bit of an edge case to ship an entire pseudo class for this. The author knows whether there's a dropdown.<br>
&lt;masonf> una: let's not call it drop-down by the way<br>
&lt;masonf> una: we could debate the naming, but maybe let's not open that can of worms<br>
&lt;masonf> una: can't you do this with style queries?<br>
&lt;masonf> una: do we need to launch this now?<br>
&lt;masonf> q+<br>
&lt;lea> qq+<br>
&lt;astearns> ack lea<br>
&lt;Zakim> lea, you wanted to react to una<br>
&lt;masonf> lea: with style queries you can only target the element not the descendants<br>
&lt;masonf> una: author still has control<br>
&lt;astearns> ack Lwarlow<br>
&lt;lea> does it have a picker in iOS? Is that considered a picker?<br>
&lt;masonf> lwarlow: to clarify - a select in dropdown mode always has a picker. Problem with auto appearance isn't there.<br>
&lt;masonf> lwarlow: people might write styles that don't transfer - they need to know whether a picker actually opened<br>
&lt;masonf> lwarlow: not queryable via style queries or attributes. E.g. size attribute with invalid value.<br>
&lt;masonf> lwarlow: mobile browsers have a system where it's always a dropdown, even if you have size attributes, etc.<br>
&lt;masonf> lwarlow: also useful to apply stylesheets in specs and browser implementations<br>
&lt;una> q+<br>
&lt;masonf> masonf: why did we need it in the UA stylesheet<br>
&lt;masonf> jarhar: I don't think we can use style queries to do this, but I don't know for sure. Gut says no.<br>
&lt;astearns> ack masonf<br>
&lt;masonf> una: Luke was talking about mobile not respecting size attribute. Is that what we're resolving here?<br>
&lt;masonf> una: feels like something is unexpected with mobile browsers now, right?<br>
&lt;masonf> jarhar: I'm planning to make a change to make it always the same across mobile and desktop<br>
&lt;Lwarlow> The solution would be this selector right?<br>
&lt;masonf> una: this issue would be different in that case?<br>
&lt;masonf> q+<br>
&lt;astearns> ack una<br>
&lt;lea> q?<br>
&lt;masonf> jarhar: I want the pseudo class so I can define different styles<br>
&lt;lea> q+<br>
&lt;masonf> jarhar: I Don't think there are selectors that can do the same thing<br>
&lt;Lwarlow> Q+<br>
&lt;lea> q-<br>
&lt;astearns> ack masonf<br>
&lt;lea> q+<br>
&lt;masonf> masonf: you can't match exactly what :has-picker does with just a selector<br>
&lt;astearns> ack Lwarlow<br>
&lt;masonf> lwarlow: the other aspect other than invalid size. Even if queryable, there are a number of permutations in your stylesheet. No attributes, multiple attribute, size attribute, all permutations of those, etc.<br>
&lt;masonf> lwarlow: I'm not sure we need to force browsers (from a spec perspective) to do something specific for appearance:auto<br>
&lt;masonf> q+<br>
&lt;masonf> q-<br>
&lt;masonf> lwarlow: still value in having this pseudo in appearance:auto and base. E.g. what if you have mixed modes, base on the in-page, auto on the picker<br>
&lt;masonf> lwarlow: each browser already has this, let's just expose it<br>
&lt;astearns> ack lea<br>
&lt;masonf> lea: can't easily do this with style selectors, but solution isn't an ad-hoc selector<br>
&lt;masonf> q+<br>
&lt;RRSAgent> I have made the request to generate https://www.w3.org/2025/07/24-css-minutes.html fantasai<br>
&lt;jarhar> q?<br>
&lt;masonf> lea: if we add a pseudo class, it needs to match appearance:auto<br>
&lt;Lwarlow> But that still doesn’t solve the issue (but yes we should have that)<br>
&lt;masonf> lea: I put a code snippet that shows circularity if you don't support appearance:auto<br>
&lt;masonf> lea: you said browser doesn't know if it showed a picker<br>
&lt;jarhar> q+<br>
&lt;masonf> lea: for author code, you know what you have generally. I don't know about use cases.<br>
&lt;masonf> lea: frameworks and libraries can have complex selectors<br>
&lt;astearns> ack masonf<br>
&lt;jarhar> masonf: the selector is pretty complicated, so frameworks and libraries are an actual use case<br>
&lt;lea> q+<br>
&lt;jarhar> masonf: its similar to ua stylesheets, its complicated enough that every browser has done it this way<br>
&lt;Lwarlow> It’s not even complicated it just isn’t possible…<br>
&lt;jarhar> masonf: it seems like the crux of this argument is<br>
&lt;jarhar> astearns: id like to see evidence that each browser does this<br>
&lt;jarhar> masonf: i think chromium and webkit have it<br>
&lt;lea> s/lea: for author code, you know what you have generally. I don't know about use cases./lea: for author code, you know what you have generally. I cannot think of use cases outside CSS frameworks and libraries, which can afford to have more complex selectors./<br>
&lt;jarhar> masonf: the selector youre talking about is complicated or currently impossible given the parsing rules for size, the selector is giant if it can be done<br>
&lt;jarhar> masonf: i think this comes down to naming or can it be done for everything<br>
&lt;lea> s/lea: frameworks and libraries can have complex selectors/lea: so I think the motivation is too weak to justify the complexity involved/<br>
&lt;jarhar> q-<br>
&lt;jarhar> masonf: can we return to the question of making it work for everything that has a picker?<br>
&lt;una> +1<br>
&lt;jarhar> masonf: its not possible for a browser to know whether it tried to open a picker<br>
&lt;jarhar> masonf: this might be a corner case<br>
&lt;Lwarlow> Q+<br>
&lt;jarhar> masonf: maybe we could just do :has-picker and make it work everywhere<br>
&lt;astearns> ack lea<br>
&lt;lea> The only reason it's complicated today is that we can't just `[size > 0], [multiple]`, which doesn't seem that complicated?<br>
&lt;masonf> lea: wanted to reply to the complex thing today. Reason is that we can't ... see comment<br>
&lt;masonf> lea: can't do attribute values today, but if we could, then<br>
&lt;lea> q?<br>
&lt;astearns> ack fantasai<br>
&lt;masonf> fantasai: I don't think we should go down the generic :has-picker thing<br>
&lt;masonf> fantasai: can we do that with pseudos<br>
&lt;lea> (that said making `:has()`work with pseudo-elements is also a common ask)<br>
&lt;masonf> fantasai: we don't have a generic use case here. Select is particular in that it has two forms.<br>
&lt;masonf> fantasai: let's do a specific select thing, therefore<br>
&lt;masonf> fantasai: I can imagine styling differently if the picker is shown, but that would be :picker-shown<br>
&lt;astearns> ack Lwarlow<br>
&lt;masonf> lwarlow: big +1 to that. Selector that just works for listbox vs. dropdown then that's great.<br>
&lt;masonf> lwarlow: especially if we don't see this being useful for inputs. There might be cases, where inputs might or might not have a picker, but probably niche enough that we don't need it<br>
&lt;masonf> lwarlow: :has-picker is doable, but :open isn't<br>
&lt;masonf> lwarlow: timing is tough, but whether you try to open a picker isn't<br>
&lt;masonf> lwarlow: :has-listbox is fine. Reason behind drop-down vs list-box isn't exposed in the platform<br>
&lt;lea> presumably `:listbox` , not `:has-listbox`?<br>
&lt;masonf> lwarlow: should be listbox rather than dropdown, because dropdown is too overloaded<br>
&lt;masonf> +1 from the scribe for something like that also<br>
&lt;masonf> annevk: I think for most other controls, you could use @supports with the picker pseudo element<br>
&lt;masonf> annevk: with select, there are two types of controls, only one with a picker. So select is indeed special.<br>
&lt;lea> q+<br>
&lt;masonf> annevk: you can tell if it supports it, but not whether it'll show one<br>
&lt;masonf> annevk: we haven't designed this part yet, maybe we should wait to define the rest first?<br>
&lt;lea> +1<br>
&lt;masonf> annevk: one concern I heard with listboxes more generally, including on desktop. On macos, there's no native ... multi-select dropdowns.<br>
&lt;masonf> annevk: That's a problem for trying to reconcile these things<br>
&lt;astearns> ack lea<br>
&lt;lea> Just to reply to Anne, select is the only control that has both a picker and in-page mode *currently*, but down the line we could end up with more. E.g. for date pickers at least, it has been brought up that being able to render them as an in-page calendar (possibly for use in a bigger control, like a date range control) could also be useful.<br>
&lt;masonf> lea: for date pickers, it might be useful to render in the page.<br>
&lt;Lwarlow> Multiple dropdown basically is only a thing natively on iOS and android. So yeah that’s an issue<br>
&lt;lea> Lwarlow: What if it defaulted to appearance: base in platforms that don't support that? Since UAs have to implement that anyway<br>
&lt;masonf> jarhar: I thought this would be easier. I could define this in the spec based on listbox mode, and keep the internal pseudo class in the impl.<br>
</details>


-- 
GitHub Notification of comment by css-meeting-bot
Please view or discuss this issue at https://github.com/w3c/csswg-drafts/issues/7422#issuecomment-3113959029 using your GitHub account


-- 
Sent via github-notify-ml as configured in https://github.com/w3c/github-notify-ml-config

Received on Thursday, 24 July 2025 15:40:42 UTC