Re: [csswg-drafts] [css-page] Should we allow resetting the `pages` counter? (#12824)

[_Page-based counters_ in css-page-3](https://drafts.csswg.org/css-page-3/#page-based-counters):
> A counter named `page` is automatically created
> and incremented by 1 on every page of the document,
> unless the `counter-increment` property in the [page context](https://drafts.csswg.org/css-page/#page-context)
  [i.e. within the applicable `@page` declaration block]
> explicitly specifies a different increment for the `page` counter. 
> The implied `page` counter is a real counter, 
> and can be directly affected using the `counter-increment` and `counter-reset` properties
> when named explicitly in those properties. 
> It can also be used in the 'counter()' and 'counters()' function forms.
 […]
> Additionally, a counter named `pages` is automatically created by the UA. 
> Its value is always the total number of pages in the document. 
> (In continuous media this is always 1.) 
> The value of `pages` cannot be manipulated: 
> while `counter-reset` and `counter-increment` statements that set it are valid,
> they have no effect.

The draft still references [CSS2](https://drafts.csswg.org/css2/#counters) instead of [css-lists-3](https://drafts.csswg.org/css-lists-3/#auto-numbering) for `counter-reset` and `counter-increment`, by the way, and it therefore does not mention `counter-set` *explicitly*. Can we exploit that loophole? I guess not really because of the property-agnostic phrase “value … cannot be manipulated”, but le me outline the suggestion regardless:

- Introduce **`page-index()` and `page-count()` global functions**.
- Allow `counter-set: pages 1` and similar (including `calc(page-count() - 1)` etc.),  
  but still neither `counter-reset: pages` nor `counter-increment: pages 0`.
- Add an optional parameter to both functions which controls their scope,
  * defaulting to a keyword like `document` or `all`,
  * also supporting [_page selectors_](https://drafts.csswg.org/css-page/#page-selectors) (including `<custom-ident>` for _named page types_)
    or something resembling them like the keywords in [`break-…` ](https://drafts.csswg.org/css-break-4/#valdef-break-before-page) values.<!--= `auto | avoid | always | all | avoid-page | page | left | right | recto | verso | avoid-column | column | avoid-region | region;`;; [`string( <custom-ident>, [ first | start | last | first-except ]? )`](https://drafts.csswg.org/css-content-3/#string-function) -->
- Consider also adding respective global functions for other _layout-dependent indexes and totals_  
  like the ones I vaguely suggested [earlier](#issuecomment-3306957554).

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


-- 
Sent via github-notify-ml as configured in https://github.com/w3c/github-notify-ml-config

Received on Friday, 3 April 2026 11:26:05 UTC