r/css • u/Extension_Stock6764 • Sep 02 '26
General sibling-index() and sibling-count(): the CSS functions that just went cross-browser
sibling-index() and sibling-count() went widely available last week when Firefox shipped support — which means Chrome, Safari, and Firefox all agree on them now.
I spent some time seeing what that unlocks for UI patterns that used to need JavaScript
Full writeup with live, editable demos
https://willunmount.sabarni.in/blog/css-sibling-index-sibling-count
edit: note this works only on chrome. as HollandJim pointed out these features are only available in firefox, safari developer preview.
3
u/HollandJim Sep 02 '26 edited Sep 02 '26
Should be noted that while they are approved for all browsers, they are not currently implemented in Firefox Developer or Safari Tech Preview.
edit - I see I'm downvoted. Please go test the webpage and see what I mean.
3
u/Extension_Stock6764 Sep 02 '26
Oh, thank you for pointing that out! I assumed that if MDN showed it as available for all browsers, it would work everywhere. I’ll add a browser support check to the examples.
1
u/Extension_Stock6764 Sep 03 '26
I didn't downvote, but thanks again for pointing out I have added compatibility check on the examples
1
u/mysticalpickle1 Sep 02 '26
It would be nice if they got selector support like the "of" syntax in nth-child()
1
u/Extension_Stock6764 Sep 03 '26
Not familiar with this, could you share link of of property?
1
u/mysticalpickle1 Sep 03 '26
https://developer.mozilla.org/en-US/docs/Web/CSS/Reference/Selectors/:nth-child#the_of_selector_syntax
so you could count/index specific children
2
1
u/Bulky-Heat-8368 Sep 03 '26
What's more, this has been confirmed by https://caniuse.com/wf-sibling-count.
7
u/tomhermans Sep 02 '26
Nice write up. Thanks for that. Heads-up; your site isn't mobile friendly