Forum Bugs

Using page counters inside string function

dauwhe
See https://github.com/w3c/csswg-drafts/issues/4740

This is a bit of a strange example, but if you assign the value of a page counter to a string, the spec seems to say (?) that you should use the value of the page counter at the time the value is assigned.

The content values of named strings are assigned at the point when the content box of the element is first created


So with this CSS

<!DOCTYPE html>
<html>
 <head>
  <style>
  @page {
     @top-center {
         content: 'counter: ' counter(page) ', string: ' string(c);
     }
  }
  div {
      break-before: page;
  }
  #div1 {
      string-set: c counter(page);
  }
  </style>
 </head>
 <body>
  <div id="div1">Div1</div>
  <div id="div2">Div2</div>
  <div id="div3">Div3</div>
 </body>
</html>


the value of the string "c" should always be one, since that was the value of the page counter when the element #div1 was created.

There is not interop on this between user agents. PDFreactor freezes the value of string "c" at the time #div1 was created. Prince and WeasyPrint use the value of the string "c" when the running head is constructed. I can't get AntennaHouse to work.

We'd certainly welcome your input on the issue!