Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions files/en-us/web/css/sibling-index/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ We include a {{htmlelement("nav")}} container and several children {{htmlelement

#### CSS

We make it visually appear as a numbered list by displaying the sibling-index before each {{htmlelement("div")}} element using the {{CSSxRef("::before")}} pseudo-element, setting the {{CSSxRef("content")}} to be the integer returned by the `sibling-index()` function.
We make it visually appear as a numbered list by displaying the list index in ::before. Since content expects a string, we set a CSS counter to the numeric `sibling-index()` function and output it with `counter()` function.

```css
div {
Expand All @@ -144,7 +144,8 @@ div {
}

div::before {
content: var(--list-index);
counter-set: ordered var(--list-index);
content: counter(ordered);
}
```

Expand Down