SiteExperts.com Logo Home | Community | Developer's Paradise | Jobs
User Groups | Site Tools | Site Information | Search

Inside Technique : Printing Techniques : Turning Off Printing

While we do not recommend preventing the printing of pages, it is possible with a very simple style sheet. With a stylesheet you can make it more difficult, but not impossible, for the user to print a web page. You define a print style sheet that turns off the display of the body causing there to be nothing to print:

  <STYLE MEDIA=print>
    BODY {display: none}
  </STYLE>

This prevents the page from printing when the user browses to the page. However, you cannot prevent the viewing and printing of the page from a browser that does not support media style sheets, or the saving of the file locally and manually remove the print style sheet.

Currently this article contains the only pages on the site with print style sheets defined (yes, printing was also an afterthought for us :-). If you choose to print other articles on this site, you will get our default screen style sheet.

With Internet Explorer 5.0, you can even write custom scripts that rearrange your page before printing. For an example, see our article, A Cure for our Printing Blues where we show you how to dynamically reformat PRE elements to fit on standard paper.

Discuss and Rate this Article