ZDNet UK


Skip to Main Content

ZDNet.co.uk - Winner of Best Business Website 2007
  1. Home
  2. News
  3. Blogs
  4. Reviews
  5. Prices
  6. Resources
  7. Community
  8. My ZDNet

 

ZDNet UK RSS Feeds


IT Jobs

Application development Toolkit

Try CSS media types to build printer-friendly pages

Shawn Morton Builder.com

Published: 23 Jun 2003 14:38 BST

  • Email
  • Trackback
  • Clip Link
  • Print friendly
  • Post Comment

As a reader of this or any other media Web site, you are undoubtedly familiar with the printer-friendly page. It is a version of an article that is free of most graphics, background colors, and advertisements. In most cases, the printer-friendly page is a separate file that requires a trip to the Web server to retrieve.

I'm going to share an example that demonstrates how to use Cascading Style Sheets (CSS) media types to format a single HTML file for both the screen and a printer.

Media types explained
The @media rule in CSS allows me to assign specific styles based on the type of device the page will be displayed on. There is no need to create separate HTML files for each device, only separate @media rules within a single CSS file. There is also no need to make a separate request from the Web server, since the switch between media types is done on the client side.

Some of the supported devices under CSS include computer screens, printers, televisions, handhelds, speech synthesisers, and Braille tactile feedback devices. Currently, however, the major browsers support only a small number of the available media types. Internet Explorer 4.5+ and Netscape 4.7+ support screen and print, while Opera 3.67+ supports screen, print, and projector.

The HTML file
The first step is to open an existing HTML page. Figure A shows a screenshot of the printer-unfriendly page I will use in this example. Listing A provides the code. Notice that the style information is presented inline for the sake of demonstration.

Figure A

Next

Previous

1 2


  • Email
  • Trackback
  • Clip Link
  • Print friendly Print with Dell

Did you find this article useful?
116 out of 232 people found this useful


Full Talkback thread

0 comments

Company/Topic Alerts

Create a new alert from the list below:





Related Jobs

SAP Functional Solution Architect

Good communication skills; Required Functional Background with 5 full project lifecycle implementation : Applied Strong knowledge of particular SAP ...

JUNIOR JAVA DEVELOPER

HTML/CSS mark up. HTML/CSS mark up - Struts action classes Error! HTML/CSS - JavaScript - Struts - Spring - Articulate with good writing skills - ...

HTML/ CSS Developer required at Leading E-Commerce site- South East

One of the most successful e-commerce companies to emerge in the UK now requires a HTML/ CSS Developer to join their highly talented team and grow ...

Discussions

harpless harpless

SAP goes big business

Friday 25 July 2008, 6:17 PM

1 comment
pjc158 pjc158

Will Drizzle rain on Sun's MySql

Friday 25 July 2008, 5:30 PM

1 comment

Featured Talkback

The fact is: Software developers today are really designers and not coders. The reason that business anlaysts exist today to model solutions is because they understand the value of designing software before writing it. All too often developers create code that has little value because they do not understand that business classes interact with other classes within the confines of a working model or pattern.

By: 1000165269

Read full story:
Making sense of agile modelling