How do I – & why should I – make a website print-ready?

Many web developers (like myself) want to believe that paper is dead. But it’s not. It’s still alive and kickin’ and continuing to try and take over the world. There are still plenty of people that print out webpages on a regular basis. And as leaders in all-things-web, developers shouldn’t ignore that, but rather make sure their websites are print-ready. That’ll show paper who’s boss… right?

When designing a website, there are a lot of features that are usually necessary – a navigation bar, comment thread, selection toggles – that aren’t necessary when the page is printed. Here’s an example: cooking blogs are all the rage. Everyone reads them. Where else do you learn how to make triple chocolate avocado black bean brownies that get you 200 likes on Instagram 🍫🥑🤩 ? While useful, those blogs have paragraphs upon paragraphs of information about the writer’s life that you don’t necessarily need in order to make your mouth-watering creation. So when you print out the recipe to stick in a drawer and never look at again follow along with while you cook, you’d like to get only the pertinent information. Not to mention that you would rather not use 10 pages of paper for a half-page recipe.

So, you eagerly ask, how do I develop a print-ready webpage without sacrificing all my great content and features? The answer is simple: @media print.

Whereas media queries are often used to change up styles on different screen sizes in cases like @media (min-width: 768px), the print media type is used to change up styles in a print view. Just like media queries for different screen sizes, you should place this declaration at the bottom of your CSS code, and only include any changes to the default code. Below is an example.

Here, I hid the nav bar, sidebar, and footer; changed the text color; and centered/resized the logo. Note that since most printers by default hide background graphics (colors, images, gradients, etc), and most people print on white paper, it’s best to be sure your website prints with dark text that doesn’t rely on any images for layout.

Notice how the code doesn’t rewrite all of the CSS, but rather notes how it looks different when it’s printed (much like the CSS version of Sesame Street’s “One of These Things is Not Like the Other”). You can also nest screen size media queries within print media queries, if you want the print view to differ on different screen sizes. This may come in handy if someone is printing a concert ticket to PDF and you want to maintain the screen ratio of the QR code on their mobile device.

In conclusion, paper sucks. But here’s why @media print is important:

People are [unfortunately] still printing web pages, and it’s our responsibility as web developers to make sure our websites look top notch in all conditions 👌

When we cut down on the content that is printed on a page, we save ink, paper, and the world 🌎

As briefly mentioned in my last example, people also print to PDF! Which is a practical and persisting (not forgetting, environmentally-friendly) way of printing 🖨