mediaAn important assumption underlying CSS1 was that web pages were viewed using a personal computer with a monitor. But there are many more ways to access a web page than simply via computer and monitor. And each of these different media have their own characteristics. They may be monochrome, limited in size, they may be "aural" and read web page content aloud. They may be television based, like WebTV. And looking toward the future, we really have no idea what they will be like. CSS2 provides a way to tailor a style sheet to the particular medium that is being used to display a page. Inside the same style sheet you can have different parts for printing, handheld devices, monitors and so on. Additionally, different style sheets can be imported depending on the medium used for browsing. In this section we will take a look at how these work. The @media ruleThe An
These statements are identical to the statements we have seen in previous sections. For example, the following rule applies a white background and black text color to the body of page when it is being printed or when it is being displayed on a handheld device. @media print, handheld { background: white; color: black } Types of mediaCSS2 provides for the following media types, as described in the recommendation
Browser supportDetailed browser support information for this feature can be found in the Westciv CSS Guide, or in our CSS Browser Support Table. Media specific importing using @importIn addition to the media rule, CSS2 allows conditional importing of style sheets based on the current medium. This means that a style sheet will only be imported when a page is being displayed in a particular medium. This is particularly useful for low bandwidth media, like handhelds, which generally are wireless based. With an imported style sheet based on the medium, only the statements specific to the particular medium need to be downloaded. To conditionally import a style sheet based on the current medium, create a standard For instance, to import a style sheet called monochrome.css when a page is to be printed or displayed on a handheld device you would create the following @import rule. @import url(monochrome.css) print, handheld For more on Hints and suggestionsMedia specific importing essentially achieves the same outcome as using the Browser supportSee the Westciv CSS Guide, or our CSS Browser Support Table. next: printing(C)1997-2001 Western Civilisation Pty. Ltd. |