3 ms·
This combination feels unnecessarily complicated to me, at least for most of the use cases shown. Suppose we want to style a list differently if it has five or
by Sinescape 3y ago
This combination feels unnecessarily complicated to me, at least for most of the use cases shown.
Suppose we want to style a list differently if it has five or more items. Since :has can detect any child element, the existence of a fifth item is a sufficient indicator that there are at least five items. So instead of ul:has(li:nth-last-child(n+5)), we could just use ul:has(li:nth-child(5)) which is quite a bit clearer in my opinion.