by cto_official · 3y ago · 0 comments
li:nth-last-child(n + 5),
li:nth-last-child(n + 5) ~ li
I don’t think :has has such limitation and I think a simple :has(:nth-child(5)) would yield the same results as :has(:nth-last-child(n + 5)). :nth-last-child(n + 5) will select the first element among five or more siblings, and :nth-child(5) will simply select the fifth element if it exists. I see no reason to write the former over the latter when you’re just wrapping it inside a :has.