I believe I tested all the solutions available on StackOverflow but none of them is working in the Chrome (72). I followed specification on W3C but everything seems to work only in a FireFox.
I just want a simple thing - add the page number using counter-increment into the printed document. I tried HTML4 and HTML5 without any results.
Is there ANY solution?
Chrome version: 72.0.3626.81 (Official Build) (64-bit)
Solution working fine in FireFox:
<!DOCTYPE html>
<html>
<head>
<title></title>
</head>
<style type="text/css">
#content {
display: table;
}
#pageFooter {
display: table-footer-group;
}
#pageFooter:after {
counter-increment: page;
content: counter(page);
}
</style>
<body>
<div id="content">
<div id="pageFooter">Page </div>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing..A LOT MORE STUFF TO FILL THE PAGES </p>
</div>
</body>
</html>
Another solution (@page is not supported in HTML5):
@page {
@bottom-right {
content: counter(page) " of " counter(pages);
}
}
As of 12/3/2015, the margin boxes like @bottom-center don't appear to be supported by the major browsers, as shown here. If you search for "@bottom-center" you'll see a whole lot of red "not supported" boxes. When you search the web it sounds like they should work but in reality they're not supported yet. Some elements of paged media work great, like page-break-after, but not the margin boxes. – James Toomey Dec 3 '15 at 20:40
Similar threads (old, no resolution for Chrome):
- Browser Support for CSS Page Numbers
- Page numbers with CSS/HTML
- Print page numbers on pages when printing html
The issue with Chromium (counter not incremented on every page): https://bugs.chromium.org/p/chromium/issues/detail?id=774830
Some of the browsers are behaving the same:
Chrome, Edge: Page: 1 Page: 1
Firefox: Page: 1 Page: 2
Safari: Page: 1 (once, near the top of the second page)