Print stylesheets: does anyone still write them, and what goes in yours?
A user asked why our documentation pages printed with the nav, footer and cookie banner taking up half the page. I'd honestly never thought about print styles.
I added a small @media print block that hides navigation, expands links to show their URLs, and avoids breaking code blocks across pages. Is there anything else worth including? Or is print a lost cause these days?
Comments · 3
A print stylesheet is mostly hiding things: nav, footer, banners, ads. Then set a readable font size, black text on white, and show link URLs after the link text with
a[href]::after. Add page-break rules for headings.Beyond hiding the chrome, set print text to black on white and use a sensible serif or simple font at a readable size. Also avoid page breaks right after headings so a title doesn't end up alone at the bottom of a page.
Test with "Save as PDF" in your browser's print dialog. Quick and no paper wasted.