24.06.2024
Note to Self: Printing PDFs from HTML documents is still cumbersome in 2024
What works:
- @page helps to style the page layout.
- break-after helps to add page-breaks before or after important elements, such as figures, tables, chapters.
What doesn't work in 2024:
- You can't have a proper header or footer without hacks, such as this combination of a sticky header & footer with a table, because margin at-rules are not implemented in modern browsers. One finds these as solutions in quite a few StackOverflow answers, but you need other software to actually render them, such as Paged.js.
- There is no simple way to have the total number of pages in a CSS variable / counter.
- The CSS page counter thing didn't work for me in Firefox 127.
Update 2024-11-25:
- Chrome added support for @page selectors in 131+, the total number of pages and cross-references on the same page. Seems to work. I hope other browsers will follow.