How7o
  • Home
  • Marketing
    MarketingShow More
  • OS
    OSShow More
    How to force quit frozen apps in Ubuntu
    Force Close an App in Ubuntu (xkill, System Monitor, kill -9)
    4 Min Read
  • Features
    FeaturesShow More
  • Guide
    GuideShow More
  • Contact
  • Blog
Reading: How to Add CSS Print Styles for Printer and Print Screen
Share
Subscribe Now
How7oHow7o
Font ResizerAa
  • Marketing
  • OS
  • Features
  • Guide
  • Complaint
  • Advertise
Search
  • Categories
    • Marketing
    • OS
    • Features
    • Guide
    • Lifestyle
    • Wellness
    • Healthy
    • Nutrition
  • More Foxiz
    • Blog Index
    • Complaint
    • Sitemap
    • Advertise
Follow US
Copyright © 2014-2023 Ruby Theme Ltd. All Rights Reserved.
How7o > Blog > Web Development > How to Add CSS Print Styles for Printer and Print Screen
Web Development

How to Add CSS Print Styles for Printer and Print Screen

how7o
By how7o
Last updated: January 30, 2026
7 Min Read
CSS print styles shown in a clean print preview layout
SHARE

I ran into a surprisingly common problem while working on a few WordPress sites: the page looked great on screen, but the printed version was a mess. That’s where CSS print styles come in. With a little setup, you can make your site look clean and readable on paper—without messing up your normal screen design.

Contents
  • The problem I faced with printing web pages
  • How print CSS works
  • Option 1: Add a dedicated print stylesheet
    • Step-by-step: Link a print CSS file
  • Option 2: Use @media print for small changes (no extra file)
    • Step-by-step: Add a print media query
    • Screen-only media query
    • Both screen and print
  • Practical print CSS ideas you’ll actually use
  • Troubleshooting
    • My print styles aren’t applying
    • Backgrounds and colors aren’t printing
    • The layout looks squeezed or breaks across pages
  • Official references
  • Related guides
  • Wrap-up

In this post, I’ll show you two practical ways to handle printing styles:

  • Add a separate print stylesheet (best for bigger changes)
  • Use @media print rules (perfect for small tweaks)

The problem I faced with printing web pages

Most sites are built for screens: flexible layouts, big navigation menus, colorful backgrounds, buttons, sidebars, and sometimes animations. But printers don’t care about any of that. When you hit Ctrl/Cmd + P, you often get:

  • Navigation menus wasting half the page
  • Background colors printing poorly (or not at all)
  • Text too small or too light
  • Links that become useless because you can’t “click” paper
  • Sidebars and widgets cluttering the printout

I didn’t want the print version to be a screenshot of the screen version. I wanted it to feel like a document: readable font, clean spacing, and no unnecessary sections. The good news: CSS already has a built-in way to target print layouts.

How print CSS works

Browsers support different “media types” for CSS. The big ones you’ll use are:

  • screen — normal viewing in a browser
  • print — print preview / printed page
  • all — applies everywhere

That means you can tell the browser: “Use these rules only when printing.” There are two main approaches.

Option 1: Add a dedicated print stylesheet

If you expect a lot of print-specific styling (hiding multiple sections, restructuring layouts, changing fonts, etc.), a separate CSS file is clean and maintainable.

Step-by-step: Link a print CSS file

Add this inside your <head> tag:

<link rel="stylesheet" type="text/css" media="print" href="printer.css">

Quick notes:

  • media="print" targets only print preview and printing.
  • For screen-only CSS you can use media="screen".
  • For both screen and print (rarely needed these days), use media="all".

Then inside printer.css, you can add print-friendly rules like hiding headers, menus, or sidebars.

Option 2: Use @media print for small changes (no extra file)

Sometimes you don’t want another file—maybe you only want to change a font, reduce spacing, or hide one section. In that case, CSS print styles using a media query are the fastest solution.

Step-by-step: Add a print media query

You can place this inside a <style> tag in your HTML, or (better) inside your main stylesheet:

<style type="text/css">
  @media print {
    p { font-family: Georgia, "Times New Roman", serif; }
  }
</style>

That rule says: “When printing, apply this font to paragraphs.” You can swap in any print-friendly styles you need.

Screen-only media query

If you want rules only for normal browsing:

<style type="text/css">
  @media screen {
    p { font-family: system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif; }
  }
</style>

Both screen and print

If you want a shared rule for both:

<style type="text/css">
  @media screen, print {
    p { font-family: Georgia, "Times New Roman", serif; }
  }
</style>

Personally, I prefer keeping “shared” rules outside media queries and using media queries only for differences. It keeps things simpler.

Practical print CSS ideas you’ll actually use

Once you start using CSS print styles, these are the most common improvements:

  • Hide navigation and sidebars: Menus, widgets, footers often don’t belong on paper.
  • Improve typography: Use a readable serif font, increase line-height, avoid light colors.
  • Show link URLs: Printed pages can’t click links, so showing the URL can help.
  • Remove backgrounds: Many browsers don’t print backgrounds by default anyway.

Here’s a sample you can adapt:

@media print {
  /* Hide common clutter */
  header, nav, aside, footer {
    display: none !important;
  }

  /* Make text more readable */
  body {
    font-family: Georgia, "Times New Roman", serif;
    font-size: 12pt;
    line-height: 1.5;
    color: #000;
  }

  /* Prevent printing weird colors */
  * {
    background: transparent !important;
    box-shadow: none !important;
  }

  /* Optional: show URLs after links */
  a[href]:after {
    content: " (" attr(href) ")";
    font-size: 10pt;
  }
}

You don’t need all of this every time—but these patterns cover most real-world print problems.

Troubleshooting

My print styles aren’t applying

  • Make sure you’re testing in the browser’s print preview (not just resizing the screen).
  • If you used media="print", confirm the file path to the CSS is correct.
  • Use !important in print rules if your normal CSS is overriding them.
  • Check if you placed the @media print block inside a broken <style> tag or missing braces.

Backgrounds and colors aren’t printing

This is often a browser setting. Many browsers disable printing background graphics by default. Print CSS can help, but user settings still matter. When in doubt, design print layouts that don’t rely on backgrounds.

The layout looks squeezed or breaks across pages

Try reducing widths, removing floats/grids for print, and controlling page breaks:

@media print {
  .container {
    width: 100% !important;
    max-width: 100% !important;
  }

  h2, h3, p {
    page-break-inside: avoid;
  }
}

Official references

  • MDN: @media (media queries)
  • MDN: Using media queries

Related guides

(Add your internal links here when you have them. Example ideas below.)

  • How to add custom CSS in WordPress (Gutenberg + theme options)
  • How to optimize CSS delivery for performance
  • Common CSS debugging tips (specificity, cascade, and DevTools)

Wrap-up

Once I started using CSS print styles, printing stopped being an afterthought and started feeling intentional. If you need full control, use a dedicated print stylesheet. If you just need a small tweak, drop in an @media print block and move on with your day.

TAGGED:CSSCSS StylingFrontend DevelopmentMedia QueriesPrint CSSWeb DesignWordPress Tips

Sign Up For Daily Newsletter

Be keep up! Get the latest breaking news delivered straight to your inbox.
By signing up, you agree to our Terms of Use and acknowledge the data practices in our Privacy Policy. You may unsubscribe at any time.
Share This Article
Facebook Copy Link Print
Previous Article CyberPanel too many redirects Laravel error fixed by restarting LiteSpeed Fix CyberPanel Too Many Redirects (ERR_TOO_MANY_REDIRECTS) for Laravel Subdomain
Next Article Set a variable in Laravel Blade using the @php directive How to Set a Variable in Laravel Blade Templates (With Examples)
Leave a Comment

Leave a Reply Cancel reply

You must be logged in to post a comment.

FacebookLike
XFollow
PinterestPin
InstagramFollow

Subscribe Now

Subscribe to our newsletter to get our newest articles instantly!
Most Popular
Add commas to numbers in PHP using number_format()
How to Add Commas to Numbers in PHP (Thousands Separator)
January 30, 2026
Set a variable in Laravel Blade using the @php directive
How to Set a Variable in Laravel Blade Templates (With Examples)
January 30, 2026
CSS print styles shown in a clean print preview layout
How to Add CSS Print Styles for Printer and Print Screen
January 30, 2026
CyberPanel too many redirects Laravel error fixed by restarting LiteSpeed
Fix CyberPanel Too Many Redirects (ERR_TOO_MANY_REDIRECTS) for Laravel Subdomain
January 23, 2026
How I Fixed Composer Dependency Errors
How I Fixed Composer Dependency Errors Using the –ignore-platform-reqs Flag (Step-by-Step Guide)
January 12, 2026

You Might Also Like

Display only the current date in Laravel using Carbon
Web Development

How to Display Only the Current Date in Laravel (Carbon Examples)

4 Min Read
WooCommerce homepage filter to hide out of stock products
Web Development

Hide Out of Stock Products from Homepage in WooCommerce (Keep Them Visible Elsewhere)

5 Min Read
Include Composer packages in plain PHP projects
Web Development

How to Include Composer Packages in Plain PHP Projects (Autoload + Example)

5 Min Read
Debug PHP like console.log using error_log and server logs
Web Development

How to Debug in PHP Like console.log (echo, error_log, WordPress debug.log)

6 Min Read

Always Stay Up to Date

Subscribe to our newsletter to get our newest articles instantly!
How7o

We provide tips, tricks, and advice for improving websites and doing better search.

Latest News

  • SEO Audit Tool
  • Client ReferralsNew
  • Execution of SEO
  • Reporting Tool

Resouce

  • Google Search Console
  • Google Keyword Planner
  • Google OptimiseHot
  • SEO Spider

Get the Top 10 in Search!

Looking for a trustworthy service to optimize the company website?
Request a Quote
Welcome Back!

Sign in to your account

Username or Email Address
Password

Lost your password?