Re: [csswg-drafts] [selectors-4] need "first-matching-sibling" combinator (#3813)

When it comes to use cases, I think the arguments for having `:nth-sibling()` are the same as for having `:nth-child()`. 

With `:nth-child()` you can target element children by their index. With `:nth-sibling()` it would be possible to target a sibling within a group of siblings. There are many cases where a group of elements are not segmented by a separate parent, but by other siblings. In example, in an article, elements are often segmented by headings and not by structuring them as children in separate elements.

If you need to apply custom styling to the first and/or last paragraph of an element? Use `:nth-child()`. 
If you need to apply custom styling to the first and/or last paragraph of a chapter, then `:nth-child()` cannot be used. This is where an `:nth-sibling()` becomes useful.

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


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

Received on Thursday, 28 December 2023 11:32:41 UTC