Print-only CSS by eckert


How many times have you printed off a webpage, only to have it spit page after page of waste from your printer?

If you have a site that people might be printing pages from, you should include a print CSS file that will allow you to print only specific items from the page.

In the head code under your normal CSS, simply insert this code

<link rel="stylesheet" media="print" type="text/css" href="http://yoursite.com/print.css" />

Next make the print.css file on your server and start setting objects to display:block if you would like it to print or display:none if you do not.

This is not the limitation of the print.css file though. You can also change font-sizes, margins, floats, etc so that the printed version of your page looks much better.

One nice feature that you can add is a line that says something like “Thanks for visiting our site and printing this page!”. Just place it in an element and add a class like class=”printmessage”. In your regular CSS just list .printmessage {display:none;} and in your print.css label it .printmessage {display:block;}.

3 Responses to “Print-only CSS”

  1. Decal Paper Says:

    Hey great website, I noticed your website when doing some research on how to develop my blog. I was just now inquiring which spam pluggin you utilize for comments as I get tons on my blog.

  2. eckert Says:

    we use the default wordpress spam plugin akismet.

  3. basekit Says:

    This is a really handy bit of code. Printing pages of waste is a pet peeve of mine. Thanks!!

Leave a Reply


It’s Called Web Design is sponsored by Seeing Interactive and powered by WordPress
Entries (RSS) and Comments (RSS).
51 queries. 0.287 seconds.