Guide to a Print Friendly Website

March 16th, 2008 by Jack Keller

print friendly stylesheet

Ever run across a good arti­cle on a web­site, but you were about to punch the time­card, or head away from the com­puter? What do you usu­ally do, you can drag it to your over­low­ing book­mark bar where you will undoubtably for­get about it for a few weeks. Maybe you post it to your del.icio.us account instead, or some other book­mark­ing site, where again you usu­ally for­get about it. I find it's help­ful to just hit command+p (ctrl+p for the PC user) and nor­mally get just an awfully layed out print of the page, and nor­mally it has some con­tent cut off, well that was use­less and not very green to waste the paper and ink right?

After a week of find­ing arti­cles and not being able to get a decent print I aimed to fix it for our site, and then write about how oth­ers could do the same. If your a designer and your get­ting a lot of traf­fic it stands to rea­son that some­one may at some point print out your arti­cle for later reading.

Step one: You can do this a few ways, the sim­plest may be mak­ing a copy of your style.css (in some cases the name may dif­fer of course) and name that file print.css. Then fire up your favorite text or CSS edi­tor and get to work on hid­ing your ele­ments that have no need to print. (nav­i­ga­tion, head­ers, back­grounds, etc. can usu­ally get tossed out for this stylesheet) using a sim­ple dis­play: none; is nor­mally quite effective.

Step two: Start to choose the selec­tors you want to hide for the print view, nor­mally I set up, jot them down or directly edit the file. You'll end up cut­ting out the dead weight before you fin­ish your edits. A very sim­ple demo below is an exam­ple of how to hide every­thing but the arti­cle for this site.

CSS:
  1. * {
  2.     mar­gin: 0;
  3.     padding: 0;
  4.     font-family: "Times New Roman", Times, serif;
  5. }
  6.  
  7. .right, .nav­i­ga­tion, .search­header, .bot­tom, #comment-form, #respond, #com­ments, ol.commentlist, .socia­ble {
  8.     dis­play: none;
  9. }
  10.  
  11. .wrap­per {
  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.     vis­i­bil­ity: vis­i­ble!impor­tant;
  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 print­ing. The main dif­fer­ence 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?
  • Facebook
  • Design Float
  • del.icio.us
  • StumbleUpon
  • Technorati
  • Digg

Posted in CSS having 1 comment »

One Response

  1. JD

    Wow this is really help­ful.
    I used to use nested tables for my design lay­out. 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 prob­lem.
    I have been curios why it works with CSS.
    This port is exactly what I needed.
    Thanks,

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