Quantcast
Channel: Dallas Clark - Web Developer, Facebook Developer, iPhone Developer, iPad Developer » script
Viewing all articles
Browse latest Browse all 12

Change the way your page prints with CSS

$
0
0

Sometimes your pages just aren't that pretty when you print them and these days users are printing a lot. Even with all the actions to try and limit printing, we're still increasing our printing by 300% each year.

With CSS we can remove anything we don't want printed, change particular parts to our liking or add more details in, anything you want to do.

You can create the CSS as a separate file (recommended) or add it into your headers. When you reference this CSS file simply add the attribute of media="print" like below:

  1. <link rel="stylesheet" href="print.css"
  2. type="text/css" media="print" />
  3.  

Inside the css file you can style anything you want or use the script below for simplicity:

  1. body {visibility:hidden;}
  2. .print {visibility:visible;}
  3.  

With the script above you can apply the class of "print" to anything you want printed and the rest of the page will be removed.

NOTE: For a better environment please try and limit the amount you personally print, use 'Print Preview' to test the scripts above.


Viewing all articles
Browse latest Browse all 12

Trending Articles