- Kept from
- CSS-Tricks
- First read
- 2026-11-12T21:38:36Z
- Kind
- News · story
Comment on Re-Implementing :nth-child() With Modern CSS by Urdu Nigaar
This is a really clever way to make :nth-child() feel dynamic. Using sibling-index() together with if() and mod() to adjust the A and B values on the fly makes the logic much easier to follow than the usual An+B notation. I especially liked how the range and multiple cases build up step by step from the simplest example.