W3C home > Mailing lists > Public > public-css-archive@w3.org > August 2019

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

From: Mike Bremford via GitHub <sysbot+gh@w3.org>
Date: Fri, 16 Aug 2019 11:42:36 +0000
To: public-css-archive@w3.org
Message-ID: <issue_comment.created-521981177-1565955755-sysbot+gh@w3.org>
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

This archive was generated by hypermail 2.4.0 : Tuesday, 19 October 2021 01:31:13 UTC