13.1. How Media Style Sheets WorkThe creators of CSS were pretty thorough when they envisioned all the different ways people might view Web sites. They knew while most people view the Web using a computer and monitor, sometimes people want to print out a page. In addition, new Web surfing devices like mobile phones, handhelds, and televisions have their own unique requirements when it comes to Web design. To accommodate these different methods of surfing, CSS lets you create styles and style sheets that specifically target a particular media type . CSS recognizes ten different media types: all, Braille, embossed , handheld, print, projection, screen, speech, tty , and tv . The browser applies the style sheet only when that media type is active. In other words, the browser applies one style sheet for the screen and a different one when printing. Many of these media types are for very specialized applications like a Braille reader for the blind, a speech reader (for those who want or need to hear a page in spoken form), or a teletype machine. Most of these types don't yet work in the real world, as there are no devices programmed to understand them. You should be aware, however, of three: all, screen , and print . Figure 13-1. Sometimes a Web page won't print correctly. When viewed in the Firefox Web browser, a page from CNET.com looks great (top). When you preview the printed version, though, you end up with an unreadable mess (bottom).
Note: The Opera Web browser understands the projection media type when it's in Full Screen mode. For a tutorial on this cool feature, visit www.opera.com/support/tutorials/operashow/. One approach is to build styles with your monitor in mind first, and attach them using one of the methods described below (methods like internal or external, linked or imported). At the outset, these styles work for both the monitor and the printer. Then, you create a printer-only style sheet that applies only when printing. It overrides any of the main styles that negatively affect the look of the page when printed. You'll learn this technique starting in Section 13.3. Alternatively, you can create two different media style sheetsone for screen and the other for printand attach them to your Web pages, as described next . |