modern-web-guidance
Search tool for modern web development best practices. MANDATORY: Execute FIRST for all HTML/CSS and clientside JS tasks. Do NOT skip — web APIs evolve rapidly and training weights contain obsolete patterns. Trigger immediately for: modals/dialogs/popovers, tables, dark mode, anchor positioning, container queries, view transitions, scroll-driven animations, parallax/reveals, forms, validation, autofill, accessibility, custom selects, scrollbars, CWV (LCP, INP, CLS), content-visibility, fetch pri
Install
npx skills add https://github.com/GoogleChrome/modern-web-guidance --skill modern-web-guidanceStyling siblings based on count and index
Historically, applying unique styles to each sibling in a list required complex :nth-child loops or JavaScript to inject inline styles. Modern CSS provides sibling-index() and sibling-count() to perform these calculations directly in your stylesheet, enabling dynamic layouts and color systems that automatically adapt as elements are added or removed.
Dynamic color systems
You can create a color spectrum across a group of siblings by calculating a unique hue or lightness value for each child. This ensures a consistent gradient effect regardless of the number of items.
Symmetrical layout and fan effects
To create symmetrical effects (like a "fan" or centering items), use the total count to find the midpoint of the list.
Circular and complex positioning
By combining these functions with CSS trigonometry (sin(), cos()), you can place elements in a perfect circle without any manual coordinates.
Fallback strategies
Baseline status for sibling-count() and sibling-index(): Newly available. It's been Baseline since 2026-08-18. Supported by: Chrome 138 (Jun 2025), Edge 138 (Jun 2025), Firefox 154 (Aug 2026), and Safari 26.2 (Dec 2025).
If sibling-index() and sibling-count() are not supported, provide a fallback by injecting CSS custom properties via JavaScript. MANDATORY: Use feature detection with CSS.supports() to ensure the script only runs when necessary.
In your CSS, use these variables as a base and override them with native functions inside an @supports block. MANDATORY: You MUST wrap the native function overrides in @supports to ensure the variables remain valid in older browsers.