Re: [csswg-drafts] [css-lists-3] Should automatic list-item increment adjust for ol[reversed]? (#4181)

Regarding setting the initial value of a reversed list, I'd originally felt you could do this in pure CSS with a new function `count()`, which takes a selector and returns the number of elements that match it when evaluated on the current node: so exactly the same as `:has()`, but returning an ordinal value.

You could have something like:
```css
ol[reversed] {
    counter-reset: list-item calc(attr(start integer, count(> li)) + 1);
}
```
However the comment from @emilio above, that this must be applied to any item with `display:list-item` not just `li`, made me think believe it couldn't work. But its just dawned on me that it can, like so:

```css
ol[reversed] {
    counter-reset: list-item calc(attr(start integer, count(> ::marker)) + 1);
}
```

There are numerous uses for a count() function in CSS - imagine the javascript-free layouts you could create, using only `calc`, `count` and the new trignometric functions going into css-values.

-- 
GitHub Notification of comment by faceless2
Please view or discuss this issue at https://github.com/w3c/csswg-drafts/issues/4181#issuecomment-521981177 using your GitHub account

Received on Friday, 16 August 2019 11:42:38 UTC