Guide to a Print Friendly Website

March 16th, 2008 by Jack Keller

print friendly stylesheet

Ever run across a good article on a website, but you were about to punch the timecard, or head away from the computer? What do you usually do, you can drag it to your overlowing bookmark bar where you will undoubtably forget about it for a few weeks. Maybe you post it to your del.icio.us account instead, or some other bookmarking site, where again you usually forget about it. I find it’s helpful to just hit command+p (ctrl+p for the PC user) and normally get just an awfully layed out print of the page, and normally it has some content cut off, well that was useless and not very green to waste the paper and ink right?

After a week of finding articles and not being able to get a decent print I aimed to fix it for our site, and then write about how others could do the same. If your a designer and your getting a lot of traffic it stands to reason that someone may at some point print out your article for later reading.

Step one: You can do this a few ways, the simplest may be making a copy of your style.css (in some cases the name may differ of course) and name that file print.css. Then fire up your favorite text or CSS editor and get to work on hiding your elements that have no need to print. (navigation, headers, backgrounds, etc. can usually get tossed out for this stylesheet) using a simple display: none; is normally quite effective.

Step two: Start to choose the selectors you want to hide for the print view, normally I set up, jot them down or directly edit the file. You’ll end up cutting out the dead weight before you finish your edits. A very simple demo below is an example of how to hide everything but the article for this site.

CSS:
  1. * {
  2.     margin: 0;
  3.     padding: 0;
  4.     font-family: “Times New Roman”, Times, serif;
  5. }
  6.  
  7. .right, .navigation, .searchheader, .bottom, #comment-form, #respond, #comments, ol.commentlist, .sociable {
  8.     display: none;
  9. }
  10.  
  11. .wrapper {
  12.     width: 8.5in;
  13.     padding-right: .75in;
  14.     padding-left: .75in;
  15. }
  16. ol, ul {
  17.     margin-left: 40px;
  18.     margin-right: 40px;
  19. }
  20. .descr {
  21.     margin-bottom: 20px;
  22. }
  23. .entry {
  24.     visibility: visible!important;
  25. }
  26. .footer, .info {
  27.     margin-top: 20px;
  28. }
  29. a {
  30.     color: black;
  31.     text-decoration: none;
  32. }

Put this line into your page head so that the browser will know to grab this stylesheet for printing. The main difference between this and main stylesheet is the media portion.

HTML:
  1. <link href=“http://www.yoursite.com/print.css” media=“print” type=“text/css” rel=“stylesheet” />

Share? These icons link to social bookmarking sites where readers can share and discover new web pages.
  • Digg
  • StumbleUpon
  • del.icio.us
  • NewsVine
  • Technorati
  • TwitThis
  • Google
  • Facebook
  • DZone
  • DesignFloat

Posted in CSS

One Response

  1. JD

    Wow this is really helpful.
    I used to use nested tables for my design layout. I used to have my designs print out all chopped up but I never knew why?
    I of course now use CSS and I now don’t have that problem.
    I have been curios why it works with CSS.
    This port is exactly what I needed.
    Thanks,

Leave a Comment

Please note: Comment moderation is enabled and may delay your comment. There is no need to resubmit your comment.

About media|extranet

We're a group of industry professionals who would like to give a little bit back to the community. Although we've just begun, we plan to do some write-ups on Advertising, Marketing, Development (.NET, PHP, Flash, Flex, AIR, JavaScript Frameworks, etc.) and Copywriting. Visit our contact section if you would like to see us cover something that we're not. The links below are for our writers, visit them directly if you have a project in mind that could utilize their talents.

Visit Snackbox Labs