by Lammy · 2y ago · 0 comments
h2,h3,h4,h5,h6,h7,h8 {break-after: avoid-page;}
img, svg, table, canvas {break-inside: avoid;}
a::after {content: " (" attr(href) ")";}
Explanation:- Avoid printing section headers at the bottom of one page with the section content left headerless at the top of the next page.
- Prefer printing graphics and figures on whole pages instead of split across pages.
- Print out the URL of every hyperlink instead of having links only as useless underlined text.
For many years now, and alongside my "regular" CV, I've had a Markdown to PDF script that uses @page and @media in a small HTML template and essentially creates custom 1-pagers in US format. Instant recruiter turnaround.
In between this and the OP's table splitting trick, this was a good 15m spent on HN.
I don't think that h7 and h8 exist?! Are you sure this is necessary? And why no h1?
https://developer.mozilla.org/en-US/docs/Web/HTML/Element/He...
No h1 because there is only ever one of those and it's at the top of the first page.
I have used, too:
footer {
page-break-inside: avoid;
}
summary {
page-break-after: avoid;
}
body {
min-width: 992px;
}
Explanation:- I usually don't want to break the page footer.
- Similar to headings, usually it is not desirable to produce a break after the summary element (for details element). If the details elements are never longer than the page, `details {break-inside: avoid;}`can be useful.
- Avoids rendering the mobile version of a page
Like if I've got
<a href="https://www.google.com/">https://www.google.com/</a>
Will it print like this? https://www.google.com (https://www.google.com)