How to style your website for print with CSS

Abbey Fitzgerald's Layout avatar

What does print have to do with the web?

Most of us live online, getting all of our information from the web. We’re connected all day, every day, from many devices. You may have heard that print is dead when, in fact, that certainly isn’t true! We may not print as frequently as we once did, but there are situations where viewing content on a device is just no substitute for having a hard printed copy to look at. Do you have valuable how-to content, redeemable coupons, directions, portfolio examples, or anything else that users would prefer to see in print? If so, setting up custom print rules on your website will certainly help shape the experience for your users.

Office printer

How to design for print

All the magic is contained within CSS by defining print-specific styles. You may find it helpful to create a separate print.css stylesheet so it is separate from all your other styles. Keep in mind that not all sites have a print style sheet; this is an additional feature and step in the development process. If no print styles are specified, the default styles are used for printing. We will be defining styles to make things more efficient for print, which will override any defaults.

Remember: You should never make changes on a live site. Our free local development app, Local, will help you simplify your workflow and safely experiment with your site. Try it today!

The naming convention and specific styles will be unique to your own project’s stylesheet, but these concepts will apply. After the basics are added, go through the default stylesheet of your website and look for any unique situations that need print styles to ensure the best printing experience.

Color and layout considerations

Most people prefer to print in black and white due to the expense of colored ink. Also, there is a higher contrast when text is black and printed on white paper. You’re probably familiar with media queries, as they are critical in modern, responsive web design. Media queries are also necessary for creating print styles.

This is what will make text in the body black, and get rid of any background color for best printing:

@media print {
body {
color: #000;
background: #fff;

Chances are, the text will print out in Times New Roman. There’s nothing wrong with that, but what if you want to specify a different font? Just like you did in your default styles, this can be done in print as well. While we’re at it, let’s not forget the line height.

body {
font: 13pt Tahoma, Geneva, sans-serif;
line-height: 1.5;

Hiding unnecessary elements

You’ve probably been conditioned to keep the display: none to a minimum, but this is entirely okay for your print styles. By hiding some elements, you are giving your users a better way to print and keeping anything unnecessary from the hard copy. The goal is to allow them to effectively print out the most important content, not the exact web page.

There are page elements that are not necessary, like navigation, footer, sidebar, and background images, so this is where our display: none will come in handy.

@media print {
nav, aside, footer {
display: none;

section {
background: none
/* section had a patterned background in the default styling which is best removed in the print style */

Articles are often printed, so it is great to have each article start on a separate page. It is much easier for the user to organize their printouts if key information is grouped together and not spread across multiple pages.

By adding this to your print stylesheet, the articles will always start on a new page:

article {
page-break-before: always;

Keeping the unordered lists together on the same page is a great idea too:

ul {
page-break-inside: avoid;

Let’s take it a step further and do the same for headings, images, blockquotes, tables, and other list elements:

h1, h2, h3, h4, h5, h6 {

img {

blockquote, table, pre {

ul, ol, dl {


<img class="aligncenter wp-image-12547 size-full" src="" alt="print-styling-03" width="1022" height="480" />
<h3>Page margin measurements</h3>

We will be adding a width of 100% to the body and article and getting rid of any unnecessary margins or padding. That way we can strip out any unnecessary spacing.

body, article {
width: 100%;
margin: 0;
padding: 0;

Here is where the spacing can really be fine tuned for printouts. It’s not too often that you see centimeters in web design, but it works great for the purpose of determining borders on the page. The @page rule is how we will target the spacing. This example will allow for 2cm around all the borders. This measurement can be customized to allow for more or less space. For instance, your users may want to take notes and allowing for a larger margin would be helpful.

@page {
margin: 2cm;

If pages are intended to be printed and put in a binder, keep in mind that there is the option to adjust the margins for every other page. Left page is for pages 1, 3, 5… and the right page is page 2, 4, 6…

@page :left {
margin: 1cm 3cm 1cm 2cm;

@page :right {
margin: 1cm 2cm 2cm 3cm;

First-page customization comes in handy in certain instances. By using the :first page pseudo-class, the styling of the first printed page can be determined:

@page :first {
margin: 1cm 2cm;


Does printing stress you out? Here are a few tips to print your project like a pro.

Image and intro text ideas

These may or may not apply to your site, but they are good to note nonetheless.

To prevent images from being cut off and bleeding over the edge of the printed page, adding a declaration of a max width will prevent this.

img {
max-width: 100% !important;

A nice welcome message is a great addition. Print content will be around for awhile, so it is always nice to include a friendly message or reminder.

header:before {
display: block;
content: "Thank you for visiting my website at   Please check back for upcoming specials and new products.";
margin-bottom: 15px;
padding: 5px 8px;
font-style: italic;

Now that we’ve covered some of the print consideration basics, it is easy to incorporate these ideas into your print stylesheet. Although print is not what we ultimately think of when we use the web, it is a great way to provide your users with the same great experience no matter how they are accessing content.

Comments ( 4 )

  1. Jacques

    June 20, 2018

    Thanks for the info Abby it was very helpful. It took me a while to find it because I didn't know exactly what I was looking for to solve my problem.

  2. Ajik Bali

    April 13, 2018

    Hi Abbey,
    I already read it from the beginning till the end. But do not find how to connet the css to the html code, i mean to the any print button or link.
    sorry, i'm extremely newbe, thanks Ajik Bali

    • Romi

      April 20, 2018

      Hi ajik,

      Whatever css you have written for the webpage just copy and paste it again in the stylesheet with the media query print, like---

      /* style.css file*/
      @media print
      padding: 10px;

      now in your html just create a print button, like -

      now see, when you click on the button the printed content of the webpage will hold the styles of the webpage.

  3. michel

    April 4, 2016

    thanks for this article (y)

  4. Jodi

    August 30, 2015

    Thanks for sharing this article Abby!

    I've just stumbled across this blog today and find this SUPER useful, and something I hadn't really considered before, but certainly makes sense. There's been many a time where I've printed a website and the print version is disorganised, messy and seems to be all over the shop. Will definitely keep this in mind for the future.

Join the discussion