CSS print Media Type

Beginner
⏱️ 7 min read
📚 Updated: Jul 2026
🎯 4 Examples
Media Queries

What You’ll Learn

The print media type lets you apply CSS only when a page is printed or viewed in print preview. Create clean, paper-friendly layouts by hiding chrome and tuning typography.

01

@media

Media query.

02

print

Paper output.

03

Hide UI

Nav & ads.

04

pt units

Print fonts.

05

page-break

Page control.

06

vs screen

Media types.

Introduction

Screen styles often include dark headers, floating sidebars, and large buttons — great for browsing, wasteful on paper. When users press Ctrl+P (or Cmd+P on Mac), the browser switches to the print media type and applies your print-specific CSS.

Unlike media features such as min-width or pointer, print is a media type that describes the output medium itself.

Definition and Usage

Wrap rules in @media print { } to target printed output. Hide navigation, use readable font sizes in pt, set black text on white backgrounds, and control page breaks for long articles.

💡
Beginner Tip

Print styles do not appear on the normal screen. Always test with the browser’s Print Preview (Ctrl+P) to see your @media print rules in action.

📝 Syntax

Use the print keyword as the media type:

syntax.css
@media print {
  /* Styles for printed output only */
}

/* Shorthand — same as above */
@media print {
  .no-print {
    display: none;
  }
}

Common Media Types

  • screen — Computer and phone displays (the default browsing context).
  • print — Printed pages and print preview.
  • all — All media types (use sparingly).
  • speech — Screen readers and speech synthesizers.

print vs screen

@media screen { } Styles for monitors and phone displays. This is the default when no media type is specified in many contexts.
@media print { } Styles for paper output and print preview. Hides UI chrome and optimizes readability.

print vs overflow-block: paged

@media print Media type — targets the print output medium directly. The most common approach.
@media (overflow-block: paged) Media feature — matches when block-axis overflow is paginated. Complements print styles.

Basic Example

print-basic.css
@media print {
  .navbar {
    display: none;
  }

  body {
    font-size: 12pt;
    color: #000;
    background: #fff;
  }
}

Default Value

If you define no @media print rules, the browser prints using your screen styles. That often wastes ink on dark backgrounds and navigation bars.

Syntax Rules

  • Use pt (points) or in (inches) for print typography instead of px or vw.
  • Prefer black text on white: color: #000; background: #fff;
  • Hide with display: none or a reusable .no-print class.
  • Control breaks: page-break-before, page-break-after, page-break-inside: avoid.
  • Combine types and features: @media print and (min-width: 5in) { }.

Related Topics

@media print .no-print { display: none; } page-break-inside: avoid

⚡ Quick Reference

QuestionAnswer
Keywordprint (media type)
Syntax@media print { }
When it appliesPrinting and print preview (Ctrl+P)
Hide navigation.navbar { display: none; }
Print font sizebody { font-size: 12pt; }
Avoid page breakspage-break-inside: avoid
Browser supportUniversal — all browsers

When to Use print

Reach for @media print when paper output matters:

  • Articles and recipes — Let users print clean content without site chrome.
  • Invoices and receipts — Format transactional pages for paper records.
  • Documentation — Provide readable technical docs without sidebars.
  • Reports and tables — Control page breaks so tables do not split awkwardly.
  • Legal pages — Ensure terms and privacy policies print legibly.

👀 Live Preview

@media print styles only appear in Print Preview (Ctrl+P). This diagram shows the typical before/after:

On screen
Navigation bar

Dark header, buttons, and sidebar chrome visible.

When printed

Article Title

Navigation hidden. Black text on white paper. Readable 12pt body copy.

Examples Gallery

Practice print with navbar hiding, no-print classes, page breaks, and link URL expansion.

📜 Core Patterns

Optimize layouts for paper output.

Example 1 — Hide navbar and adjust font size

The classic beginner demo from the reference tutorial — hide navigation and set readable print typography:

print-navbar.css
.navbar {
  background: #1e293b;
  color: #fff;
  padding: 0.75rem;
}

@media print {
  .navbar {
    display: none;
  }

  body {
    font-size: 12pt;
    color: #000;
    background: #fff;
  }
}
Try It Yourself

How It Works

Open Print Preview to see the navbar disappear and body text resize to 12pt.

Example 2 — Reusable no-print class

Mark any element to exclude from printed output with a single utility class:

print-no-print.css
@media print {
  .no-print {
    display: none !important;
  }
}
Try It Yourself

How It Works

One class keeps print CSS maintainable. Add it to any element that should not appear on paper.

Example 3 — Avoid awkward page breaks

Keep headings with their content and prevent figures from splitting across pages:

print-page-break.css
@media print {
  h1, h2, h3 {
    page-break-after: avoid;
  }

  article, figure, table {
    page-break-inside: avoid;
  }
}
Try It Yourself

How It Works

Page-break properties keep printed documents readable. Test with a multi-page article in Print Preview.

🛠 Usage Tips

  • Test with Print Preview — Always verify with Ctrl+P before shipping print styles.
  • Use pt for fonts12pt body and 14–18pt headings read well on paper.
  • Strip backgrounds — Save ink by removing dark backgrounds and box shadows.
  • no-print utility — One reusable class is easier than many one-off selectors.
  • Combine with @page — Set margins with @page { margin: 2cm; } inside print blocks.

⚠️ Common Pitfalls

  • Expecting screen preview — Print styles only appear in Print Preview, not on the normal page.
  • Calling it a propertyprint is a media type, not a CSS property.
  • Printing dark themes — Dark backgrounds waste ink and reduce contrast on paper.
  • Forgetting buttons — Hide interactive controls that are useless on paper.
  • Absolute positioning — Fixed and sticky elements often print incorrectly; hide or reset them.

♿ Accessibility

  • Readable contrast — Black on white provides the best print legibility.
  • Do not rely on color alone — Printed pages are often grayscale; use text labels too.
  • Preserve content — Hide chrome, not the main article or data users need.
  • Link URLs — Show href values so printed references remain useful.
  • Font size — Avoid fonts smaller than 10pt for body text.

🧠 How print Works

1

User opens Print Preview

Ctrl+P switches the rendering context to the print media type.

Trigger
2

Browser applies @media print

Print-only rules override screen styles for paper layout.

Match
3

Page breaks and margins apply

Content flows across pages with your break and typography rules.

Layout
=

Clean printout

Professional paper output without wasted ink or broken layouts.

🖥 Browser Compatibility

The print media type has universal support — it has been part of CSS since the earliest media query specifications.

Baseline · Universal support

Print media queries

Works in every browser including Chrome, Firefox, Safari, Edge, and Opera.

99% Global support
print media type 99% supported

Bottom line: @media print is one of the safest CSS features to use in production. Always verify visually in Print Preview.

🎉 Conclusion

The print media type is essential for professional web content. With @media print, you hide navigation, tune typography for paper, and control page breaks so printed pages look intentional.

Test every print stylesheet in Print Preview (Ctrl+P). Pair with overflow-block for advanced paginated layouts when needed.

💡 Best Practices

✅ Do

  • Test Print Preview
  • Use pt for fonts
  • Hide nav and ads
  • Black text on white
  • Show link URLs

❌ Don’t

  • Print dark backgrounds
  • Hide main content
  • Use px for print fonts
  • Skip page-break rules
  • Call it a property

Key Takeaways

Knowledge Unlocked

Five things to remember about print

Use these points when building printer-friendly pages.

5
Core concepts
Ctrl 02

Print Preview

Ctrl+P to test.

Testing
12 03

12pt body

Print fonts.

Typography
X 04

Hide chrome

Nav & ads.

Pattern
BR 05

Page breaks

Avoid splits.

Layout

❓ Frequently Asked Questions

What does the CSS print media type do?

The print media type targets printed output. Rules inside @media print { } apply when the document is printed or viewed in print preview (Ctrl+P). Use it to hide navigation, adjust fonts for paper, and control page breaks.

How is print different from a media feature?

print is a media type that describes the output medium (paper). Media features like min-width or pointer describe device capabilities. You can combine them: @media print and (min-width: 8in) { }.

What should I hide when printing a webpage?

Hide navigation bars, sidebars, ads, buttons, cookie banners, and decorative backgrounds. Keep the main article content, headings, and essential data visible.

How do I test print styles?

Open your browser print preview with Ctrl+P (Windows) or Cmd+P (Mac). Chrome, Firefox, Safari, and Edge all render @media print rules in the preview before you print.

Is @media print widely supported in browsers?

Yes. The print media type has been supported in all browsers for decades. It is one of the most reliable CSS media queries for production use.

Practice in the Live Editor

Open the HTML editor, add @media print rules, then test with Ctrl+P in Print Preview.

HTML Editor →

About the author

Mari Selvan M P
Mari Selvan M P 🔗

Developer, cloud engineer, and technical writer

  • Experience 12 years building web and cloud systems
  • Focus Full Stack Development, AWS, and Developer Education

I write practical tutorials so students and working developers can learn by doing—from databases and APIs to deployment on AWS.

5 people found this page helpful