Skip to content

CSS sibling-index() and sibling-count() functions #1460

Open

Description

@lilles

Description

sibling-index() and sibling-count() can be used as integers in CSS property values to style elements based on their position among its siblings, or the total number of siblings respectively. These functions can be used directly as integer values, but more interestingly inside calc() expressions.

Example:

li {
  margin-left: calc(10px * sibling-index());
}

Example use cases for this are staggered animations setting the animation- or transition-delay based on the sibling position, and building a radial menu.

These functions are shipped in all engines, but all have wpt failures.

Specification

https://drafts.csswg.org/css-values-5/#tree-counting

web-feature

https://web-platform-dx.github.io/web-features-explorer/features/sibling-count/

Test Links

https://wpt.fyi/results/css/css-values/tree-counting/

Additional Signals

No response

Activity

  1. github-actions commented on Sep 23, 2026

    @github-actions

    This comment was automatically generated based on the information you provided. Please don't edit it.

    Below is additional information about the web feature (from the web-features project) which is referenced in your proposal.
    If this doesn't accurately correspond to your proposal, please update your initial comment to include web-features: <feature-id>.
    To find feature IDs, use the web-features explorer.

    Feature sibling-count() and sibling-index()

  2. jakearchibald commented on Oct 8, 2026

    @jakearchibald
    Contributor

    This has now shipped across browsers, so this should close, right?

  3. jakearchibald commented on Oct 8, 2026

    @jakearchibald
    Contributor

    Ah, folks have pointed out this is about the remaining test failures.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions