Skip to content

[css-forms-1] Should ::picker(select) match :popover-open? #10775

Open

Description

@josepharhar

We resolved to make ::picker(select) be a part-like pseudo-element here: #10758

However, there were questions about whether we should make it match :popover-open.

I believe that since ::picker(select) is a part-like pseudo-element, it should match :popover-open.

Here are some reasons I understood were brought up that it shouldn't match :popover-open with my counterarguments:

  • There shouldn't be more than one way to detect this state in CSS, so we should use select:open instead of ::picker(select):popover-open.
    • I think it's totally fine for us to provide both, and it's beneficial to authors because if we don't support one of the two then authors might just write code that doesn't work and give up without knowing there is another way to do it. @emilio may have also mentioned that there are other use cases in CSS where there are more than one way to do something?
  • Allowing :popover-open to be matched reveals internal implementation details of <select>.
    • I think this is fine because I am putting in the HTML spec that ::picker(select) is a popover, so any spec-abiding implementation must make this work. I'm sure that other uses of part-like pseudo-elements must reveal other sorts of internal implementation details about the element they match like this, so why should this one be disallowed? I'd like to try giving an example of this but I'm not up to speed on the other proposed or completed usages of part-like pseudo-elements.

Activity

  1. nt1m commented on Aug 24, 2024

    @nt1m
    Member

    Allowing :popover-open to be matched reveals internal implementation details of <select>.

    In general the less API surface there is, the less problems are likely going to come up in the future. Web APIs should be designed to last. We could decide that popover is no longer the right paradigm for pickers in the future. Should we be stuck with supporting :popover-open then?

    There shouldn't be more than one way to detect this state in CSS, so we should use select:open instead of ::picker(select):popover-open.

    Quoting @fantasai:
    We want form controls to act like they’re built into the language, not built out of author facilities in the language; and that their full functionality can be implemented without those author facilities.

    :open / :closed covers the different use cases fine.
    Should developers care that this is a popover honestly? I think what really matters for the purposes of styling and animation is that it's an element in the top layer. It doesn't really matter if it's a popover or a dialog.

  2. yisibl commented on Aug 26, 2024

    @yisibl
    Contributor

    As a developer, for me I don't care if it's a popover.
    It would be much simpler and less expensive to learn to standardize on one :open for all scenarios.

    Also, even if both selectors are supported, the CSS compressor will be compressed to the shorter :open in the future, and from that perspective, :popover-open will be used by fewer people in the future.

  3. annevk commented on Aug 26, 2024

    @annevk
    Member

    I think requiring :popover-open to match would very much go against our earlier decision not to reuse ::part(). Whether or not ::picker(select) points to an HTML element with a popover attribute set is an implementation detail. If implementations want to implement ::picker(select) without an element node they should be allowed to do that. ::picker(select) needs to behave like popovers in a number of respects, but it shouldn't be required to use the exact same mechanism underneath.

    Now I suppose we could update the :popover-open requirements to say that ::picker(select) also needs to be matched, but that seems kinda pointless to me given that we already plan to add :open to select elements.

  4. josepharhar commented on Sep 3, 2024

    @josepharhar
    ContributorAuthor

    The draft HTML spec that I've written explicitly says that ::picker(select) maps to an element which has the popover attribute, and we resolved on making it a part-like pseudo element. I still don't see how adding a special case to not parse :popover-open is helpful, but since its functionally the same as :open for popover animations and therefore doesn't limit what authors can do, and there seems to be significant pushback, I'll let it go and add a console message in this case to help point developers to the accepted syntax.

    Proposed resolution: add a special case to not parse :popover-open for the ::picker(select) pseudo-element.

  5. tabatkins commented on Sep 3, 2024

    @tabatkins
    Member

    While we resolved against using ::part() itself, we did resolve to make it a "part-like pseudo-element", and that means it acts like ::part() but is just spelled differently. Notably, ::part() does expose implementation details like what pseudo-classes and pseudo-elements are usable on the element, and this is intentional. (As opposed to the other pseudo-elements, which only allow a limited subset of pseudo classes/elements after them.)

    I don't think we should try to diverge ::picker() from the agreed-upon concept of part-like pseudos.

  6. nt1m commented on Sep 3, 2024

    @nt1m
    Member

    I don't think we should be locking ourselves in unnecessarily by exposing things that are not useful and may potentially cause a compat hazard later if something needs to change. While popover may seem like an appropriate concept to re-use now, it might not be the case later.

    Fwiw, I'm also OK with making :popover-open not match instead of not parse (there's a subtle difference there), if that preserves the technical purity a bit more.

  7. dbaron commented on Sep 4, 2024

    @dbaron
    Member

    I agree that we should stick to the concept of part-like pseudo-elements.

    If we add an exception here, how many other exceptions will we add? How much working group time and implementor time will be spent implementing those exceptions, that could have been used for something else? And how much author confusion will result?

    I really do think that what we're trying to do here is to provide an author-facing model for complex built-in widgets that exposes to developers that these widgets are composed of more basic pieces of web technology. This has been the plan for a long time (>20 years) because it seemed like the only practical way to standardize the stylability of complex widgets, and I still think this is the case. I thought that the conclusion in #9951 (comment) agreed with this concept but concluded that we would not use the name ::part() because it was for author-built components and for standardized components that were built in to the Web platform.

  8. annevk commented on Sep 4, 2024

    @annevk
    Member

    I don't think I argued against making it a part-like pseudo-element? Not sure why that is being revisited.

    I argued against exposing the fact that ::picker() matches a particular type of element. I think the tradeoff is between forever enshrining that this needs to act as if there was an HTML element with a popover attribute set underneath versus keeping it more general and only requiring more "obvious" pseudo classes to match, such as :hover. Who knows, we might introduce a better suited element such as <popup> at one point which would not match :popover-open. In order to reuse it here we'd have to add special cases at that point.

    The other argument against it matching is that it introduces redundant API surface. This is slightly weaker, but whenever we don't have to, I'd definitely prefer not introducing redundant ways to do the same thing, especially if the redundant way is significantly more verbose and addresses fewer scenarios.

  9. tabatkins commented on Sep 4, 2024

    @tabatkins
    Member

    The markup structure of a base ::picker() is going to be precisely standardized, I thought. That's required, in practice, for it to be predictably styleable, which is the point of the base feature in the first place. Any changes we make to the markup structure are going to be constrained by compat, or gated behind a new appearance keyword if they're too radical.

    Looking back at the spec for part-like pseudos, I see that it doesn't actually carry over the bit of ::part()'s definition that allows arbitrary pseudo-classes to be used on it, but that was the intention. I'll look into getting that fixed.

  10. mfreed7 commented on Sep 4, 2024

    @mfreed7
    Contributor

    The markup structure of a base ::picker() is going to be precisely standardized, I thought. That's required, in practice, for it to be predictably styleable, which is the point of the base feature in the first place. Any changes we make to the markup structure are going to be constrained by compat, or gated behind a new appearance keyword if they're too radical.

    This was my thought as well. It feels very confusing to developers to see that the <select> is using a popover (per spec), but have :popover-open not match (or worse, not parse!) on that popover.

  11. annevk commented on Sep 5, 2024

    @annevk
    Member

    I see it a bit differently. Internal shadow trees allow us to more precisely define the observable behavior of certain built-in elements and give us a handful of shortcuts in defining such behavior, but:

    1. We still get to decide as to what the overall API should be and what details of the shadow tree we wish to reveal and expose and which we hold back for future enhancements.
    2. Implementations are free to implement it differently as long as the observable behavior is the same.
  12. css-meeting-bot commented on Sep 5, 2024

    @css-meeting-bot
    Member

    The CSS Working Group just discussed [css-ui] Should `::picker(select)` match `:popover-open`?, and agreed to the following:

    • RESOLVED: don't create a special exception to not parse :popover-open on ::picker(select)
    The full IRC log of that discussion <chrishtr> jarhar: this is a topic that was spun out of ::picker. There is disagreement about whether :popover-open should match. We already resolved that ::picker is a part-like pseudo element.
    <jarhar> q?
    <una> q+
    <chrishtr> jarhar: there is the question of whether it should match :popover-element. I and some others think it should because that's the default for part-like pseudos. Others don't like it because it would reveal internal details
    <masonf> q+ simon
    <gregwhitworth> ack una
    <chrishtr> una: clarifying question: would this match both open and popover-open, or just popover-open?
    <chrishtr> jarhar: there is no contention about :open, discussion is just for :popover-open.
    <chrishtr> una: so with your preferred resolution it'd match both?
    <chrishtr> masonf: yes
    <chrishtr> una: ok I agree with that, just checking
    <chrishtr> dbaron: select matches open, and picker matches popover-open
    <chrishtr> una: if you have appearance:base-select for both the in-page and picker, then select:open would be the same as picker:poover-open
    <zcorpan> ack simon
    <chrishtr> una: if you only have appearance: base on the select and not the picker, then you can only match select:open because the picker doesn't exist
    <chrishtr> fantasai: seems like it has to exist
    <chrishtr> annevk: exists but doesn't match because it isn't styleable
    <chrishtr> annevk: isn't that the case for other pseudo-elements anyway?
    <chrishtr> fantasai: exists but not styleable
    <dbaron> (I'm not actually 100% sure that ::picker(select):popover-open doesn't work when ::picker(select) is appearance:auto... although I *think* that's the case
    <chrishtr> fantasai: if we allow popover-open to apply to the picker then it won't apply if not in base mode?
    <una> q+
    <chrishtr> jarhar: the picker element exists but in auto mode it can't be opened as a popover because it never opens
    <fantasai> ::picker(selecT) { appearance: base; } ::picker(select):popover-open { appearance: auto; }
    <chrishtr> fantasai: what about applying appearance:auto if :popover-open, what will that do?
    <chrishtr> annevk: would be a loop?
    <chrishtr> masonf: which picker you open depends on timing. If it's already open then it wouldn't close?
    <chrishtr> annevk: normally in CSS if the computed value changes then what you see changes
    <chrishtr> masonf: if so then there would need to be some code to handle it
    <gregwhitworth> ack una
    <dbaron> (I think this is sort of exposing a problem with making `appearance` apply separately to `::picker(select)`... it probably normally would have been restricted.)
    <chrishtr> una: maybe this is a difference between part-like and regular pseudo elements?
    <chrishtr> fantasai: this was relaxed before for pseudos
    <chrishtr> q+
    <chrishtr> una: second question: just updated my demos when I updated them to the new syntax. e.g. focus-visible didn't apply any more. Wanted to see if this ok. Also is there an issue with specificity?
    <zcorpan> Demo for ::before:hover (seems like this is not implemented) https://software.hixie.ch/utilities/js/live-dom-viewer/saved/13060
    <gregwhitworth> ack chrishtr
    <fantasai> select:open ::picker() vs select ::picker():popover-open - same specificity
    <chrishtr> fantasai: specificity would be the same
    <gregwhitworth> chrishtr: wanted to bring us back, popover: open question jarhar originally raised
    <gregwhitworth> masonf: the issue being discussed is their unique capabilities for this scenario
    <jarhar> proposed resolution: don't create a special exception to not parse :popover-open on ::picker(select)
    <masonf> +1
    <una> +1
    <chrishtr> +1
    <dbaron> +1
    <zcorpan> +1
    <emilio> +1
    <sanketj_> +1
    <gregwhitworth> RESOLVED: don't create a special exception to not parse :popover-open on ::picker(select)
    <gregwhitworth> Zakim, end meeting
  13. ByteEater-pl commented on Sep 15, 2024

    @ByteEater-pl

    Maybe it should be contingent on the value of appearance, so that in the future, when an alternative, possibly better rendering of select is implemented without this part, authors can choose. This opens, it seems to me, a path to the desired by many commenters forward compatibility. (But carves in stone the currently planned variant with the part, so that, even if one day considered legacy, implementations will have to continue supporting it.)

    In general, each model of some control type with some innards exposed would need its own value of appearance. And if a need arises, multiple can exist for the same control type.

    And two values of apperarance would always be available. Namely, none, which gives an element no special rendering or parts, and default (auto or base?) with no exposed parts but with possibly some special implementation-dependent rendering (satisfying some quite general constraints) and a limited set of applicable CSS properties.

  14. changed the title [-][css-ui] Should `::picker(select)` match `:popover-open`?[/-] [+][css-forms-1] Should `::picker(select)` match `:popover-open`?[/+] on Mar 28, 2025
  15. added and removed
    css-ui-4
    on Mar 28, 2025
  16. css-meeting-bot commented on Mar 19, 2026

    @css-meeting-bot
    Member

    The CSS Working Group just discussed [css-forms-1] Should `::picker(select)` match `:popover-open`?.

    The full IRC log of that discussion <jarhar> annevk: we discussed this many months ago, but its come up again because there are some demos and tests using this
    <jarhar> annevk: despite there not really being agreement
    <lwarlow> 1+
    <lwarlow> q+
    <jarhar> annevk: we dont think it should work because there is already an api for this, :open. it can do everything this can do. duplicate api doesnt seem great to expose. ill leave it at that
    <jarhar> chrishtr: this issue was discussed 2 years ago at this call i believe
    <jarhar> chrishtr: it was resolved
    <jarhar> annevk: it was resolved not to create a parsing exception, but not resolved whether it should match or not
    <jarhar> annevk: we would never have agreed to matching
    <jarhar> annevk: the resolution there is clear that its about parsing
    <jarhar> masonf: my memory was different. i agree that the resolution says parsing exception, but the discussion was about carving out things for it
    <jarhar> ntim: i remember having reservations about matching duplicate api surface
    <jarhar> masonf: css has all kinds of duplicate ways to do things
    <jarhar> ntim: no reason to add more
    <jarhar> lwarlow: the open pseudo class is already duplicative for dialog and details
    <jarhar> masonf: first child and nth child 1 do the same thing, should we remove first child?
    <jarhar> annevk: for dialog and details i would say that html changing the attributes was the wrong choice
    <jarhar> annevk: first child and other things are different purposes
    <jarhar> masonf: how so?
    <jarhar> annevk: one is a superset of the other?
    <jarhar> masonf: one is a strict superset of the other which is what were talking about here
    <lwarlow> q-
    <masonf> q+
    <jarhar> lwarlow: because its a popover, i dont see a problem with it matching popover open. at the same time, its a pseudo, if browsers can do where it doesnt match if its this pseudo. i would go back to this is shipped, is there compat problems?
    <jarhar> lwarlow: people generally do tend to be using the open pseudo class but not sure
    <jarhar> ntim: that was the case until i discovered that mdn advice was to use popover-open
    <astearns> ack dbaron
    <jarhar> dbaron: there is existing spec text which says that this works. the definition of element backed pseudos says that it can match as a real element, and all other pseudos match as they would on that real element
    <jarhar> dbaron: my reading of that resolution of not creating an exception means that the spec text applies
    <jarhar> annevk: the html side is not defined because its just a div
    <jarhar> annevk: a div element doesnt match popover open
    <jarhar> annevk: i disagree with the pr
    <emilio> Doesn't match != Doesn't parse fwiw
    <jarhar> dbaron: i dont have much follow up other than thats how we interpreted the resolution, so we implemented and shipped based on that resolution
    <astearns> ack masonf
    <jarhar> masonf: theres a missing part of the html spec, it calls popover algorithms on it but its missing the fact that it has the popover attribute
    <jarhar> masonf: the way it has to behave is as a popover, thats why the popover api was invented, and it needs to play nicely with other popovers
    <jarhar> masonf: its very clear to me that it is a popover, we need to fix that in the spec, but i dont see us going a different direction
    <lwarlow> q+
    <jarhar> masonf: given that it is a popover, its confusing to say that it is a popover except for this special carve out. that is more confusing than just saying its a popover
    <jarhar> masonf: thats why i think the earlier resolution was the correct one
    <jarhar> annevk: im not sold on that. keith also raised a related thing here that the popover semantics should generally apply and not just to a single appearance, which i am sympathetic to. then its less clear what the popover is
    <jarhar> annevk: generally we will need some lower level hooks to integrate in the various popover bits. select as a whole can participate in that, not just in its base appearance mode
    <jarhar> masonf: but the picker only gets rendered and shows up in base appearance modes
    <jarhar> annevk: theres behaviors around popovers, like you open one and other gets closed. you could do that for the native picker
    <jarhar> masonf: that seems orthogonal
    <jarhar> annevk: then its about the select element as a whole how it integrates with popover
    <jarhar> masonf: we could go down that road, but what we shipped is that it is a popover when its appearance base
    <jarhar> annevk: im not solved on the stylesheet and check other integration points
    <jarhar> annevk: for the stylesheet there are conflicts
    <jarhar> annevk: the popover styles ended up overriding the picker styles
    <jarhar> lwarlow: thats because webkit uses a pseudo class instead of an attribute selector?
    <jarhar> lwarlow: if its a popover and it has the popover attribute, then it has popover attribute styles?
    <fantasai> pseudo-classes and attribute selectors have the same specificity
    <jarhar> annevk: those need to be overriden, and the current style rules dont have specificity to do that
    <jarhar> ntim: we tried to have ::picker(select), and that didnt override popover styles
    <fantasai> but pseudo-elements don't have specificity iirc ...
    <jarhar> ntim: anne added a pseudo for the picker to undo it, and thats very hacky
    <jarhar> ntim: thats how we solved the specificity problem
    <jarhar> astearns: you all asked for this issue to be put on the agenda. it would have been great to have some of those details in the issue
    <jarhar> astearns: we could have hashed some of this out in the github issue
    <dbaron> pseudo-classes and attributes have the same specificity, so this could be about what order things are in the UA stylesheet
    <jarhar> astearns: ill take a look at the rest of the agenda items to prompt people to add to them
    <astearns> ack lwarlow
    <jarhar> lwarlow: we should encourage authors to use select:open instead of popover-open because auto appearance mode might not be impelmented using a popover, but as a ua you might want to let users to set a background color on the picker when its open
    <jarhar> lwarlow: the chromium non-mac ones you could do that
    <jarhar> lwarlow: the other thing is to say that currently chromium uses popover for one of its selects, and you can style it in auto mode, which is maybe not desirable but maybe tangential
    <jarhar> lwarlow: for consistency i think it makes sense to match, but for authors its probably better
    <astearns> ack fantasai
    <masonf> luke can you clarify the chromium thing you just mentioned?
    <jarhar> fantasai: question to think about would be does popover open match if youre using a date picker for example? if not, hows that going to interact with future extensions to date pickers?
    <masonf> q+
    <jarhar> fantasai: with appearance auto, does popover open apply? if it doesnt, then what happens on an apple watch where we dont allow appearance base styled picker because it wont behave properly?
    <jarhar> fantasai: they will get inconsistent results
    <lwarlow> q+
    <jarhar> fantasai: we either need to make popover open match whenever open matches, or we should make it never match and make people use open
    <astearns> ack masonf
    <jarhar> masonf: i agree we should encourage developers to use open, but i also think we should make popovers match popover open
    <jarhar> masonf: date picker isnt a popover, so it shouldnt match
    <jarhar> masonf: base select should match since it is a popover
    <jarhar> masonf: thats the more confusing fact. if developers are wondering why it isn't matching and they have to come find this meeting, thats my objection
    <jarhar> fantasai: its straightforward: its a pseudo, so it doesnt get what applies to an element
    <jarhar> masonf: pseudo classes apply to pseudo elements
    <jarhar> fantasai: ones that are markup based dont, and this one is sort of markup based
    <jarhar> fantasai: it would be weird if it applies to some pickers but not others
    <jarhar> fantasai: over time as we do more controls popover open might or might not work on others. if we allow it then we encourage authors to use it and then they will run into trouble
    <jarhar> lwarlow: i dont understand the discussion about date pickers because the picker pseudo doesnt match them
    <jarhar> masonf: what you just said applies to select, which is only a popover
    <jarhar> lwarlow: date pickers will have it, and they will be defined to be a popover
    <jarhar> astearns: we are out of time
    <jarhar> zakim, end meeting
  17. mfreed7 commented on Mar 19, 2026

    @mfreed7
    Contributor

    I think this comment still summarizes our view here: #10775 (comment)

  18. annevk commented on Mar 19, 2026

    @annevk
    Member

    The subsequent comments still summarize ours. 😊

  19. lukewarlow commented on Mar 19, 2026

    @lukewarlow
    Member

    I think we need Mozilla for a tie breaker here 😅 . whatwg/html#11729 (comment) @emilio sounded like he could go either way.

  20. emilio commented on Mar 19, 2026

    @emilio
    Collaborator

    No, that comment was meant as "I support defining the shadow tree using existing primitives like popover rather than magic".

    The behavior Chromium implements falls out of that, which is select:open matching and ::picker(select):popover-open matching as well.

    But of course the DOM structure of the shadow tree should be properly defined. That includes specifying the tagname and popover attribute value that the picker would have, and defining the UA sheet in a way that actually works, without requiring random internal pseudo-classes.

    I could live with defining the picker as a magic div that doesn't have a popover attribute and doesn't match :popover-open but somehow is a popover, but that seems kinda silly tbh?

  21. tabatkins commented on Mar 20, 2026

    @tabatkins
    Member

    I could live with defining the picker as a magic div that doesn't have a popover attribute and doesn't match :popover-open but somehow is a popover, but that seems kinda silly tbh?

    Same and agreed. As I said in my earlier comment, the whole point of this base appearance stuff is to give authors a dependable, predictable styling structure. Because behavior is involved here, too, that naturally folds into the same reasoning: the fact that a base-select is (or isn't) using popover is part of the exposed behavior contract, and should be well-specified and consistent across browsers. Because popovers have observable side-effects (like responding to other popovers), we cannot change the behavior to some future similar feature, at least not without the future similar feature intentionally maintaining heavy back-compat in enough ways that it doesn't matter that it's something new.

    So if we use popover, we're stuck with popover. If we're stuck with popover, we should expose that it's a popover, in the normal way that popovers are exposed in any other usage. We should aim for absolutely minimal difference from the author-facing API as much as possible. If we want to change to something else in the future, we'll need a switch for that.

    On the other hand, if we want to make something identical to popover except in a few exceptional cases, we need to define exactly what that magic is, and then we're still stuck with it. At that point we're just defining a new feature that's special-cased to select, and we need to justify why it's worth expanding the defined API surface like that, and why we're not exposing this new thing to authors, too.

  22. annevk commented on Mar 21, 2026

    @annevk
    Member

    Well I think we might want to expose this to web developers in the future too for custom elements. Luke had proposed something already. And I think there too you would not want the pseudo-class to apply necessarily as you want full API control.

    All the other popover integration points are not really API, that’s what makes this different.

  23. lukewarlow commented on Mar 21, 2026

    @lukewarlow
    Member

    Fwiw I think custom element authors would want to pseudo class to match. They often don't like the fact they need to do :state(open). Also if popover-open didn't match it would make transitioning between spawning an attribute and using the element internals harder.

    But that's probably a discussion for another time.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions