CSS Print Media Queries

Format web pages cleanly for physical printers and PDF exports.

Use @media print to define styles that only apply when a user prints the page or exports to PDF. Common techniques include hiding navigation bars, ensuring black text, and expanding margins.

Key Takeaways: CSS Print Media Queries

Mastering CSS Print Media Queries helps you write clean and reliable CSS code. Follow standard conventions, test edge cases, and keep logic simple. Try running the code example below and complete the exercises to build confidence.

CSS Print Media Queries Code Example

CSS
@media print {
  nav, footer, .btn-no-print { display: none !important; }
  body { color: #000; background: #fff; font-size: 12pt; }
  a[href]::after { content: " (" attr(href) ")"; }
}
Output
Hides UI controls and prints URL links next to anchors
Free sign-in required · Google login available
Finished this lesson?
Mark it complete to track your progress.

Stuck on something?

Ask the community in the CodesInTech forum.

Need a developer?

Learning on your own is great — and when you need professional help, our team builds custom software, websites and mobile apps for clients worldwide.

Explore Our Services