Creating Print Stylesheets for Your Blog

2006 April 6
by Karen

I spent part of today writing print stylesheets for our Movable Type weblogs and my own personal blog. One thing I think is crucial with print stylesheets is that less is more. This means a couple of things when you are trying to optimize the page for print. First, that stylesheet you have been using all along needs to be set up so that it is for screen only. This means in Movable Type you take and change this:

<link rel=”stylesheet” href=”<$MTBlogURL$>styles-site.css” type=”text/css” />
to this
<link rel=”stylesheet” href=”<$MTBlogURL$>styles-site.css” type=”text/css” media=”screen” />

If you don’t do this you will be fighting your screen styles when you create your print stylesheet. This is bad and makes lots more work. Having the stylesheet only be for media-type “screen” is the default in WordPress so you don’t have to worry about this. Once you have done this you can start formatting the print version from scratch. Without a print stylesheet you’ll get a very plain looking page. THIS IS OKAY! In fact its what you want so that you can add minimal formatting to make your page look good when it is printed.The most important thing you will want to do in your print stylesheet is “hide” the things on your page that you don’t want to show up when you print. For example you might not want to show your banner or navigation when you print. To do this you use a CSS property called “display”. The display property is somewhat difficult to explain what you need to know is that can be used to hide things on a web page. So set it to {display: none;} which basically means “don’t display this element”. You can do other helpful things like making the background white and all the text black, and setting up rules for page breaks. Below is my print stylesheet for this blog.

/* Print Style Sheet */
/* added print stylesheet for LWC */

@media print {
body { background:white; color:black; margin:0 }
#sidebar {display:none;}
#footer {display:none;}
.navigation {display:none;}
#commentform { display:none }
a {color:#000000;}

/*Some rules about Page breaks */
h1, h2, h3, h4, h5, h6 { page-break-after:avoid;
page-break-inside:avoid }
img { page-break-inside:avoid;
page-break-after:avoid; }
blockquote, table, pre { page-break-inside:avoid }
ul, ol, dl { page-break-before:avoid }
}

This is a really simple print stylesheet but it does gets the job done. It didn’t take me long to create and it makes life a lot easier for users when they print my site. The downside is that if you want a screen shot of my site you are going to actually have to take one rather than printing the site or sending it to PDF. I think that this is okay though. Based on what I’m seeing in my server log files. Few people are visiting my site in person. Which I interpret as meaning that content is king and my design doesn’t matter as much. If I saw different traffic in my server logs I might decide to do things a little differently. Because maybe people would want to print what they were seeing not just the content. This is an issues you need to be sensitive to when you create a print stylesheet. However, my opinion is if you have a content intensive site that having a print stylesheet which drastically changes how the pages looks is okay. Especially if your site doesn’t print well otherwise. However, as with any design decisions you should get feedback from your users when making this type of decision.

2 Responses leave one →
  1. 2006 April 6

    There’s a little more to it with Movable Type: Without a print style, or at least unless the regular style is display-only, any long post (anything that requires more than one print page) ***will not print properly*** in Firefox..

    I find this infuriating, and probably disregard some posts that I might otherwise use as source material because MT is so insistent that I either use IE or that I not print out anything to read later. WP, as you note, does a fine job of printing without any special stylesheet…

    So, huzzah to you for fixing the MT-based weblogs you’re associated with. I wish the company would fix it on a general basis, but I guess proprietary software providers tend to prefer other proprietary software…

  2. 2006 April 6

    Walt,

    Yes, I discover what you are talking about with Movable Type. I hate to tell you but it isn’t just Firefox that the printing doesn’t work. I didn’t have success with printing long posts in either Safari or Opera as well. WordPress doesn’t have a print stylesheet but the main stylesheet is just set up for “display”. People with Movable Type blogs should think about fixing their stylesheet so that they are for “display” only. I outlined how to do this above. Also if you are trying to print a Movable Type blog from Firefox you can go under the “View” Menu, and select “Page Style”, “No Style”. This will turn the CSS off completely. Another alternative is to install the Web Developer’s extension and use it to turn the CSS off. Both of these methods should get you a copy for print that at least includes all the information.

Leave a Reply

Note: You can use basic XHTML in your comments. Your email address will never be published.

Subscribe to this comment feed via RSS