Styling siblings with CSS has never been easier. Experimenting with sibling-count and sibling-index
September 19, 2025

If I were to divide CSS evolutions into categories, then last year was probably the year that ended with animations and colors getting better; This year, the end of the year seems to be about those ease-of-life features. We had one of those not that long go with :has(), but with things such as sibling-count, sibling-index, functions, and conditionals, the way we write CSS might just change for the better once again. In this article, I want to dip my toe in sibling-index() and sibling-count(), while also carefully adding some functions in the mix.
Years ago, CSS introduced the adjacent sibling selector, but it was limited in that it could only select an element that follows another element as its sibling.
Sibling selection has got more sophisticated in recent times, and here we can learn all about sibling selection in CSS today.