Can I :has all the withins?
For almost as long as there has been CSS, there have been obvious needs for the ability to write a selector for which the last thing in it is not the subject. This was recognized very, very early - it was put off in CSS1, CSS2, Selectors Level 3 and was only allowed to stay in Level 4 because we invented this profiles compromise which, at the time, made a lot more sense. As of the meeting today, it was put at risk and there were suggestions to kick the can down the road to Level 5.
This is a hard problem, there is no denying - but that there are a large number of use cases and that it is the most requested feature also seems similarly undeniable.
We have already added (with implementations in the wild) parts of this problem space because they were more finite- like :focus-within
and :target-within
. We know we need more, like:focus-visible-within
(w3c/csswg-drafts#3080). There is just no way to admit you need these two selectors without allowing that they have a union. We've talked about adding more parts still with ideas like and have talked about other parts like :has-following-siblings()
or :has-children()
, :valid-within
, :invalid-within
, and I am relatively certain this is not an exhaustive list. I am relatively certain that even if we had all of those, they wouldn't meet a lot of very normal/common use cases.
I'd like to suggest that this is a bad state to be in, in a whole lot of ways for both developers, and standards-making and resolving things here in a good way probably requires a Very Special Effort.
I would love to see if a few of us could make time to discuss the parameters here and write an explainer/faq asking and answering lots of questions in this space in a single place. Call it a CSS Note, I guess?
It seems, for example, that some things that are held out against a :has
have counterpoints about things with similar characteristics already, or how every site needs this functionality and the lack of a solution requires jumping through 16 other hoops which differ according to technical details and situation. Maybe we really are ok with that and can articulate answers to all of the questions that I get asked, but it would be nice to have this in one place that lays out, effectively criteria for success or failure and could maybe inform some vision forward.
Is this a thing that anyone would be willing on working on with me?