Re: [csswg-drafts] [css-page-3] page context counter scopes are described incorrectly (#4759)

Two things I want to add to this:

First, I need to make clear that the above interpretation "if a counter is _created_ within the page context" is absolutely critical to making page-context counters work. Without it, it's impossible to use any counter other than "page" in the page margin; it would always fall out of scope at the end of the page context (in the example below, the "preface" counter would always have the value "1"). This clearly isn't the intention. The "page" counter only works because it's behaviour is explicitly described.

Second, in order for _any_ counter other than "page" to be used in the page context, it is fairly important that counters can be created before the first page. An example:
```css
:root {
    counter-reset: preface 5;
}
@page {
   @top-center {
      counter-increment: preface 1;
      content: counter(preface);
   }
}
```
If the :root element is created and the "preface" counter initialized _before_ the first page is created, the counter at the top of the first page will be "6", the next one "7" and so on.

But if the :root element is created _after_ the first page, the counter at the top of the first page will be "1", the second page "6" and the third page "7" and so on. Because the counter doesn't exist when the first page is created, the "preface" counter is created in the first page context, then falls out of scope. On subsequent pages, the counter created by the :root element is in scope and it increments as normal.

I think it makes sense to add a line to the first block of [section 6.1](https://drafts.csswg.org/css-page-3/#page-based-counters) that:

> Counters created on the root element are in scope for all page-margin boxes

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

Received on Friday, 28 February 2020 15:51:51 UTC