The Media Attribute
The media attribute is used within both the style and link tags that attach internal and external stylesheets to HTML pages.
Using alternative media stylesheets will require both a style tag and a link tag (both placed within the <head> section) rather than the single style or link tag more commonly used. The format is:
<style type="text/css" media="all">
@import "styles.css";
</style>
<link rel="stylesheet" type="text/css" media="print" href="printstyles.css">
These tags will send the browser to two different style sheets; the first (styles.css) will apply to all screen media: monitors, PDA's, and other web-enabled devices (it should be noted, however, that neither the @import directive nor the media attribute are recognized by older browsers; thus this particular exercise won't work with Netscape 4.x and Explorer 4.x and below). The second stylesheet (i.e., printstyles.css) will apply only if the reader chooses to print out the page. If the print command is chosen, the browser will automatically go to printstyles.css and apply the styles included there.
To be fair here, I should note that Netscape 6.x and Mozilla browsers have a major conflict between the media attribute and items which use a "float" as part of their positioning in CSS. However, the conflict is easily resolved: see Meyer for details.
Why Should You Teach It?
Eric Meyer points out that most web designers are "pretty used to styling for the screen, but thinking about other media isn't a habit yet." In the case of our students, the reverse is more probably true: they may be accustomed to doing some formatting for print (e.g., adding headings and subheadings, indenting subsections, perhaps even adding graphs and charts in technical writing classes), but they're probably much less accustomed to styling for the screen. Using the media attribute within the style tag foregrounds these differences, asking students to make choices about which styles to apply for which media. The link below leads to a more detailed discussion of these differences.
Print Formats vs. Screen FormatsCitation Format:
Batschelet, Margaret. "Learning To Love the Code: HTML As a Tool in the Writing Classroom." The Writing Instructor. 2004. http://www.writinginstructor.org/files/batschelet/
(Date Accessed).
Review Process: Margaret Batschelet's
hypertext was accepted for publication following blind, peer review.