-
Notifications
You must be signed in to change notification settings - Fork 756
Description
Take the following CSS and HTML:
:root {
counter-reset: page 0; /* UA rule */
}
@page {
counter-increment: page 1; /* UA rule */
@top-center {
content: "page " string(x, first);
}
}
body {
string-set: x counter(page, decimal);
}<body>
... multi page content ...
</body>What is displayed at the top of each page? There are two conceivable options:
-
The value is "page 1" on all pages, which is the result you would get it you set the value of "x" to the value of the page counter when the string was first created.
-
The value is "page n", where page is the current page number. This is the result you would get if you evaluate the value of the page counter when the string "x" is displayed, not when its set.
Prince chooses option 2, at least for the page counter - this exact approach is used in their "essay.html" example available at https://css4.pub. I am fairly convinced this is wrong, but have realised that this is not explicit in the specification (which is here, for reference).
Why do I think this is wrong? Because it is inconsistent with the way other counter values are used. Take an almost identical example:
:root {
counter-reset: section 0;
}
@page {
@top-center {
content: "section " string(x, first);
}
}
h1 {
counter-increment: section 1;
string-set: x counter(section, decimal);
}<body>
<h1>Header</h1>
<h1>Header</h1>
<h1>Header</h1>
</body>The only difference here is that the counter is being incremented on the <h1>, not in the page rule. The intention of this is clear, and examples showing this type of approach exist in the spec and in various testcases. All agree that the value at the top of the page is "section 1".
But the only way you can get "section 1" is by evaluating the section counter when the string is set. If you evaluate it when the string is displayed, you will get the current value of the counter, which - in this example - would result in "section 3".
The page counter is not magic - it is a normal counter as described in https://drafts.csswg.org/css-page-3/#page-based-counters, and the rules marked "UA rule" in the first example would be in the UA stylesheet, or equivalent structure.
I'm prepared to concede that there is a third way to conceive of this beyond the reach of my feeble mind. Whatever the solution, I think this needs clarification in the specification.
I'll prepare a proper (tentative) testcase and would be interested to hear the results from other paged media renderers.