Re: [csswg-drafts] [css-selectors] Nearest descendant selector (#4940)

It sounds like you're describing the nearest descendent in document order, is that right? So if you had two elements that matches `.wrapper > div > .child`, only the first one would match?

```css
.wrapper > * > :nth-child(1 of .child),
   .wrapper > * > :not(.child) > :nth-child(1 of .child),
   .wrapper > * > :not(.child) > :not(.child) > :nth-child(1 of .child),
   ... and so on, depending on how deep your structure goes.
```
Not terribly elegant, but better than trying to evaluate
```css
.wrapper > * > :nth-child(1 of .child:not(:has(.child)))
```

which I think might be equivalent, although I really don't fancy proving that. Also, you probably don't have `:has()`!


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

Received on Friday, 10 April 2020 14:08:25 UTC