Using `:is()` in complex selectors selects more than you might initially think. πŸ”— bram.us/2023/01/17/using-is-… 🏷 #css #selectors
1
22
3
73
Why in the world would you use :is() in such a situation? I cannot think of a single use case that would make me even consider using :is() like that.
1
See the β€œWhy is this relevant” section in the post πŸ˜‰
1
I had seen it when I asked the question. I still don't see the logic behind ever using `.a :is(.b .c)` (unless what you really want is to catch the .b .a .c case too), whether you manually write it like that or it's generated from the way you nest things.
1
To make it clear: I cannot think of *any* use cases for the `:is(.b .c)` part in isolation and the only use case for the whole `.a :is(.b .c)` would be precisely to also select `.b .a .c` in addition to `.a .b .c`.
3
1
Maybe worth noting that .a :is(.b .c) matches a slightly larger set of things, since it matches everything matched by: .a .b .c .b .a .c .a.b .c

Jan 18, 2023 Β· 2:11 PM UTC

1
3
Yes, the wanting to match more is the only situation where it makes sense to use the whole `.a :is(.b .c)`. But using just `:is(.b .c)` on its own makes no sense to me - the result is the same as when using `.b .c`, just writing more for poorer support. Because of this...
1