Page counter

Use the counter() function to find the current page and the total number of pages.

<p>Number of this page = <span style="content: counter(page)"></span></p>
<p>Total number of pages in this document=<span style="content: counter(pages)">
</span></p>

counter() has an optional second argument specifying the counter style. If that is omitted, it defaults to ‘decimal’.

<p>Number of this page = 
  <span style="content: counter(page, lower-roman)"></span></p>
<p>Total number of pages in this document=
  <span style="content: counter(pages, upper-roman)"></span></p>