CSS sibling-index formula generator
Choose a child count, delay step and formula preset. Inspect the values and download CSS with a fallback for the chosen number of children.
Generate sibling-based CSS formulas locally. JavaScript is needed for the preview.
How it works
The CSS Values draft counts all element children of a parent, starting at 1. For index i, count n and step s, forward delay is (i − 1) × s; reverse delay is (n − i) × s. Our normalized progress is (i − 1) / max(1, n − 1), giving a lone child 0. Spaces around subtraction are required in calc().
Values are computed without intermediate rounding. The table shows progress to four decimals; generated CSS preserves numeric precision. The numeric nth-child fallback matches the selected count. Add an animation-name and keyframes in your own stylesheet to animate the generated delays.
Worked examples
Five children, 100 ms step
Forward delays are 0, 100, 200, 300 and 400 ms. The third child has normalized progress 0.5.
Reverse and single-child cases
Three children at 75 ms have reverse delays 150, 75 and 0 ms. One child has progress 0, without division by zero.
Frequently asked questions
Why does my calc() subtraction fail?
Do hidden elements count?
Can I put the formula on the parent?
Does the preview prove browser support?
Why is the first progress item invisible?
What limits does this generator impose?
Sources
- CSS Values 5 — Tree Counting Functions (editor’s draft) (checked 2026-11-14)
- CSS Values 4 — calc syntax (checked 2026-11-14)
Last reviewed 2026-11-14; next review due by 2027-02-12. The method is written out above so you can check our math.