Skip to content
Back to Concepts
CSS UniverseTrack 7: Responsive ArchitecturePrint Stylesheets
Responsive Architecture · Track 7 CapstoneCore Concept 29

Print Stylesheets & Clean PDF Output

Every e-commerce receipt, resume, and medical portal requires physical paper printing. Learn how @media print strips useless navigation bars, prevents cards from being sliced across page breaks, and automatically prints link URLs!

1. Mental Model: Continuous Pixels vs. Discrete Physical Paper

The web is an infinite scroll continuous canvas. But when sent to a printer, the browser must divide your page into rigid physical paper boundaries (like A4 or US Letter sheets).

Kill the Clutter

Hide navbars, sidebars, video players, and action buttons. Paper cannot be clicked!

Save Black Ink

Invert rich dark themes to crisp black text on pure white paper.

Prevent Page Slicing

Use break-inside: avoid; so an invoice row isn't cut across sheets.

2. The Essential Print CSS Toolkit

@media print {
/* 1. Hide interactive elements */
nav, footer, .sidebar, button, .ads { display: none !important; }
/* 2. Print readable link URLs */
a[href^="http"]::after { content: " (" attr(href) ")"; font-size: 80%; }
/* 3. Protect tables and cards from being split in half */
.invoice-card, tr { break-inside: avoid; }
}
/* Configure physical paper margins */
@page {
size: A4 portrait;
margin: 20mm;
}

3. Interactive Studio: Web View vs. Print Sheet Preview

Global Website Navbar

Official Customer Receipt

Invoice #INV-2026-9042

Pro Cloud Subscription (1 yr)$120.00
Priority CDN Bandwidth$24.00
Total Paid$144.00
View online receipt

First-Year Student Traps: Print Styles

  • 1.Browsers strip background colors by default! To save expensive printer ink, Chrome and Safari strip all background-color values when printing. If you have essential color badges or highlight chips, force the browser to print them using: print-color-adjust: exact; -webkit-print-color-adjust: exact;.
  • 2.The Legacy page-break-inside Syntax: Older browsers used page-break-inside: avoid. The modern standard is break-inside: avoid. For maximum browser compatibility across all print engines, declare both properties together!
Next Masterclass · Track 8 Transitions & Animation

CSS Transitions & Timing Functions

Smoothly interpolate property state changes with transition-duration, cubic-bezier curves, and GPU acceleration.

Continue to Concept 30