CSS Values Level 5 introduces `sibling-index()` and `sibling-count()` — two new functions that return an element's position among its siblings and the total sibling count as integers. This eliminates the need for Sass-generated `:nth-child()` rules or JavaScript-injected inline styles for staggered animations, equal-width tabs, hue distribution, circular menus, and z-index stacking. The post covers practical patterns, key gotchas (Shadow DOM scoping, `display:none` still counting, custom property evaluation timing, performance at scale), browser support (Chrome/Edge 138 and Safari 26.2 shipped; Firefox in progress), `@supports` fallback strategy, and accessibility considerations around visual reordering vs. DOM order.

12m read timeFrom smashingmagazine.com
Post cover image
Table of contents
Patterns Worth StealingThe GotchasBrowser SupportAccessibility NotesWhat’s Coming
1 Comment

Sort: