Skip to content

CSS Not Applying in Print

Quick summary

Your page looks fine on screen but prints incorrectly because screen styles do not apply to print media by default.

Why this happens

  • CSS is scoped to screen media only (media='screen')

  • Background colors and images are not printed by default

  • Print-specific styles are missing or incorrect

  • Elements that should be hidden on print are still visible

Minimal example

✗ Broken code
/* No print styles — page prints with default styles */
.nav { display: flex; }
.sidebar { display: block; }
✓ Fixed code
@media print {
  .nav, .sidebar, .ads { display: none; }
  main { width: 100%; }
  body { font-size: 12pt; }
  * { -webkit-print-color-adjust: exact; }
}

Add @media print rules to hide non-essential elements, adjust the layout for paper width, and ensure colors print correctly.

How to diagnose

  • Use DevTools print preview (Ctrl+P) to see what prints

  • Check if the stylesheet link has a media attribute limiting it to screen

  • Look for @media print rules in your CSS

How to fix

  • Add @media print rules to adjust layout for paper

  • Use -webkit-print-color-adjust: exact to force background printing

  • Add display: none in @media print for elements that should not print

  • Remove restrictive media attributes from stylesheet links

How to prevent

  • Always test print output during development

  • Write print-specific CSS alongside screen CSS

  • Use @media print to hide navigation, ads, and interactive elements

Related Resources

Related Glossary

Related Lessons

  • CSS

    Learn CSS including media queries.

← Back to language