title: How to store the last counter value in css and display as content in html?
body: <p>For example, my CSS looks like this:</p>
  
  <pre><code>.page-number:after { counter-increment: page; }
  </code></pre>
  
  <p>When show as content, for example 6 pages:</p>
  
  <pre><code>.page-number:after { 
     content: 'Page ' counter(page) ' of';
  }
  </code></pre>
  
  <p>I want to store the last counter -which is 6 - and print it out after each item. Is that possible to do that?</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-css lang-css prettyprint-override"><code>ul {
    list-style: none;
    counter-reset: page;
    padding: 0;
  }
  .page-number {
    counter-increment: page;
  }
  .page-number:before {
    content: 'Page ' counter(page) ' of'
  }</code></pre>
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;p&gt;I want to use counters to print '6' after each item. eg. page 1 of 6 &lt;/p&gt;
  &lt;ul&gt;
    &lt;li class="page-number"&gt;&lt;/li&gt;
    &lt;li class="page-number"&gt;&lt;/li&gt;
    &lt;li class="page-number"&gt;&lt;/li&gt;
    &lt;li class="page-number"&gt;&lt;/li&gt;
    &lt;li class="page-number"&gt;&lt;/li&gt;
    &lt;li class="page-number"&gt;&lt;/li&gt;
  &lt;/ul&gt;</code></pre>
  </div>
  </div>
  </p>
  
  <p>My <code>.page-number</code> is with position fixed, which will be display for all of the pages printed.</p>
  
  <p>updated:</p>
  
  <pre><code>@media print {
  body { margin: 0; }
  thead { counter-reset: pages; }
  .page-number:before { counter-increment: pages; content: " "; }
  .page-number:after { counter-increment: page; }
  .page-number:after { content: "Page " counter(page) " of " counter(pages); }
  }
  </code></pre>
  
  <p><a href="https://codepen.io/anon/pen/OQNreQ" rel="nofollow noreferrer">https://codepen.io/anon/pen/OQNreQ</a></p>