Summary:
The sibling-index() and sibling-count()
CSS functions allow an element to be styled using its index among its siblings and its total count
of siblings (including itself), respectively. These functions produce integers and can be used with elements anywhere that an integer is allowed, including in calculations.
We intend to enable these functions in Firefox Nightly builds behind the layout.css.tree-counting-functions.enabled pref.
Bug:
Bug 1953973 - [css-values] Add sibling-count() and sibling-index()
Specification:
https://drafts.csswg.org/css-values-5/#tree-counting
Standards Body:
CSSWG / W3C
Platform Coverage:
All
Preference:
layout.css.tree-counting-functions.enabled — Bug 2045705 to enable in Nightly
DevTools Bug:
N/A
Extensions Bug:
N/A
Use Counter:
N/A
Standards-Positions Discussion:
https://github.com/mozilla/standards-positions/issues/1194 — Positive
Other Browsers:
- Blink: Shipped since Chrome 138
- WebKit: Shipped since Safari 26.2
web-platform-tests:
https://wpt.fyi/results/css/css-values/tree-counting