CSS Snippet

Print Stylesheet Recipe

Difficulty: Easy

When users print a page, they want a clean, readable document, not screenshots of your nav bar. A small `@media print` block can hide chrome, expand link URLs inline, force black-on-white text, and control page sizing and breaks. Drop these recipes into any project that publishes long-form content (articles, receipts, invoices, recipes).

Code Snippets
/

Print Stylesheet Recipe

Print Stylesheet Recipe

When users print a page, they want a clean, readable document, not screenshots of your nav bar. A small `@media print` block can hide chrome, expand link URLs inline, force black-on-white text, and control page sizing and breaks. Drop these recipes into any project that publishes long-form content (articles, receipts, invoices, recipes).

CSS
Easy
2 snippets
css-media-queries
css-fonts-typography
css-display

712 views

10

The first thing every print stylesheet does is hide the parts of the page that only make sense on screen: navigation, ads, banners, share buttons. Use display: none !important because authors of those components often have specificity high enough to win without the bang. The second job is contrast: many printers are monochrome, and dark mode pages look terrible printed, so force white background and black text. The link-expansion trick (a[href]::after { content: " (" attr(href) ")"; }) prints the URL right after the link text, so the printed copy is still useful as a reference; exclude in-page anchors and javascript: links so you do not get noise. page-break-inside: avoid keeps figures from being cut in half across pages.