Re: [csswg-drafts] Request for a "checked-within" pseudo class (#3027)

I’ve been thinking about this the past day or so due to a question someone asked me on the Twitters, and as far as I can tell, `:has()` does indeed obviate the need for “within” selectors.  The following would seem to have equivalent specificity:

```css
nav:focus-within {…}
nav:is(:focus, :has(:focus)) {…}
```

Plus one could use `:where()` to intentionally lower the specificity, if desired.

Admittedly, the `:is()` construct is a little more baroque than a “within” equivalent, but it might be worth waiting to see how often authors use those sort of patterns before deciding what needs a “within” shortcut.

(Alternatively, we could decide to “within” all the pseudo-classes that might need it by defining them as aliases for their `:is()` equivalents.  As a CSS author _and_ an author of CSS explanatory materials, I’d be fine with that.)

-- 
GitHub Notification of comment by meyerweb
Please view or discuss this issue at https://github.com/w3c/csswg-drafts/issues/3027#issuecomment-999625713 using your GitHub account


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

Received on Wednesday, 22 December 2021 14:40:41 UTC