-
Notifications
You must be signed in to change notification settings - Fork 719
[selectors] Add pseudo-classes for
being a drop-down box vs a list box
#7422
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Is there interest in standardizing this pseudo-class (and make it also available to author CSS)? cc @mfreed7 Via git blame of WebKit's html.css I found https://bugs.webkit.org/show_bug.cgi?id=220376 -- I think a pseudo-class as suggested here would be less prone to bugs like this (compared to attribute selectors). cc @pxlcoder Via git blame of Gecko's html.css I found https://bugzilla.mozilla.org/show_bug.cgi?id=1643246 where attribute selectors were replaced with a pseudo-class. cc @emilio @heycam |
It certainly seems tricky to select this based on attribute selectors, so I'm supportive of trying to standardize a pseudo class. Picking a name will be tricky. I'm not sure I like |
HTML's wording is "list box" for |
I believe the |
How about "list box" and "drop-down list box"? (Not sure about "list box" vs "listbox".) |
"Drop down" or "drop down list box" seem pretty clear (even though they are "pop up menus" on Mac). But just "list box" by itself is not clear, because I honestly wouldn't remember which one you meant without comparing it to the other term. I think if you had "multiple list box" (or similar*) and "drop down list box" as the two terms, then they'd both be clear, even in isolation.
|
It's not necessarily multi-select, though. <select size=5>
<option>this is still single-select list box
<option>foo
<option>bar
select> |
We could define only a pseudo-class for the drop-down, and rely on the select:drop-down-list-box {}
select:not(:drop-down-list-box) {} |
+1 to the idea of targeting the idea of having a dropdown. Perhaps something like |
I’m ambivalent about the extra dash, really. |
Good question. I would say no. The date widgets are not guaranteed to have a drop-down or a popup, it would be conforming to have a control with only spinners, for example. The color well is specified to have a "color picker" that is separate from the color well, but nothing says it has to be a drop-down. Firefox on macOS opens a popup window for the color picker. Since the need is specific to the |
A few names to consider
Example usage:
or without type selector (when not using
It is probably better in terms of ergonomics to have two pseudo-classes for the two states, e.g.:
Since it will only match |
It seems to me that if this is only ever going to apply to input[type=date]:has-dropdown { doesn't match, even when the date picker "drop down menu" is present } As for I vote for Interesting side reading on "drop-down" vs "dropdown": https://www.chicagomanualofstyle.org/qanda/data/faq/topics/HyphensEnDashesEmDashes/faq0153.html. Perhaps we should use "menu" instead? |
I don't think "menu" distinguishes
vs
|
+1 to "put Relying solely on Or if we're pretty sure that |
So it sounds like For the other state, we have:
In https://drafts.csswg.org/indexes/ I see several "no-" but no "without-", so the former seems more CSS-y and is also shorter. Thus, I suggest we go with |
Looking at that list, I see that these Working my way back from the suggested If tl;dr If we have |
I don't think we need to stick with pure English rules for this; we're not writing a sentence. I think sticking with |
Might be good to reuse the well known CSS
|
I think only |
Yeah, and I wouldn't really consider them "well-known" either. I couldn't tell you what |
I should be able to remotely attend the TPAC CSS meeting either Thursday or Friday, but only before lunch. cc @astearns |
Sidenote: If authors had the ability to numerically compare attribute values, they would be able to select those elements using this snippet: select[size>1],
select[multiple] {
/*🎉 */
} This, in turn, would make a lovely custom selector as well: @custom-selector :--with-listbox [size>1], [multiple];
select:--with-listbox {
/*🎉 */
} |
@bramus not sufficient for the UA stylesheet, at least, since browsers need to get cases like |
@astearns is it possible to move this issue to some time before lunch (either Thursday or Friday)? |
The CSS Working Group just discussed The full IRC log of that discussion |
Based on the fact we now have
If it does match then I haven't read the full discussions from before but it's possible the assumptions no longer hold true. For example if we were to change multiple to be a dropdown when in base appearance mode, in some cases you couldn't always target just based on attributes alone. |
Adding this to the agenda as it would be useful to resolve on something. This is a soft blocker for base appearance listboxes. |
See whatwg/html#7050
Chromium supports a
:-internal-list-box
pseudo-class in the UA stylesheet, which matcheselements that render as a list box instead of as a dropdown box.
Gecko similarly supports
:-moz-select-list-box
in the UA stylesheet.WebKit seems to use attribute selectors instead, although I think it's not entirely accurate since the decision per spec depends on the parsing result of the
size
attribute. (Demo:)
Web developers could rely on the
multiple
attribute being present to target list boxes, but that might not always work so well, in particular if you're writing CSS that should work for arbitrary HTML.I think it makes sense to add a pseudo-class that matches
select
elements that are list boxes, e.g.:select-list-box
. To match drop-downs, you can doselect:not(:select-list-box)
.Spec: https://drafts.csswg.org/selectors/
The text was updated successfully, but these errors were encountered: