Publishers of technology books, eBooks, and videos for creative people

Home > Articles > Web Design & Development

  • Print
  • + Share This
This chapter is from the book

This chapter is from the book

CSS Printing Features

Style sheets offer you the ability to hide certain portions of a page. This, in turn, makes it easy to be more printer-friendly—especially in instances like, which uses dynamic, rather than fixed, tables.

Figure 3.5 Dynamic tables can pose a printing problem.

The style sheet guide at—written by the World Wide Web Consortium (W3C) style sheet working group member Eric Meyer—uses the display property along with classes to ensure that certain parts of the page won't print.

Figure 3.6 Use the display property to hide some items for easier printing.

To recreate this feature, follow these steps:

  1. Open an existing HTML or XHTML document along with the print_style.css document found on the web site.


    For more information on class and grouping, see Chapter 1.

  2. In the print_style.css document, note the class selectors for elements that are to be prevented from printing:, table.bottom-ads, table.footer, td.left-nav *, 
    td.right-ads *, {display: none;}
  3. Add the class attribute to the tags in question.

    <td width="125" valign="top" align="right" class="right-ads">

    Here's a sample from the Style Guide at

  4. Choose to embed or link externally to the file and enter the appropriate code.

    <link href="printout.css" type="text/css" rel="stylesheet" 

    I choose to link externally, so I entered the following into the head portion of my HTML document:


    The display property is not supported by any 4.0 versions or below of Netscape or Internet Explorer. In this case, you won't be able to print out the printer-friendly version of the page, but the page will print. The display property is supported by Internet Explorer 5.x and higher on Windows and Macintosh, and Netscape 6.x for Windows and Mac. It is also supported by Opera 4.x and 5.x, and many versions of Mozilla.

  • + Share This
  • 🔖 Save To Your Account