Media Specific

One attribute that you may find useful to add to your linkrel command that attaches your stylesheet to your web page is media. The media attribute is used to restrict the use of the content of the stylesheet to particular media. For example:

<link rel="stylesheet" href="master.css" type="text/css" media="print" />

This indicates that the content of this stylesheet is only applicable when the web page is being printed out. By specifying a linkrel with media="print" after another linkrel statement you can override particular style attributes when the page is being printed so as to make the printed page easier to read.

Other media values that you can use include screen to specify screen specific styles (which wont be used when printing) as well as aural, braille, embossed, handheld, projection, tty, and tv.

There is even an all option to advise that the styles are to be applied for all media types. This is the default except that Netscape 4 does not recognise the media attribute at all and will ignore any linkrel tags that contain it. This means that you can specify your Netscape 4 styles in a stylesheet attached with a linkrel without a media attribute and then override it for other browsers by supplying a second linkrel with media="all".


This article written by Stephen Chapman, Felgall Pty Ltd.

go to top

FaceBook Follow
Twitter Follow