CSS stylesheets are primarily intended for use in web pages. Web browsers find the stylesheet for a document by looking for xml-stylesheet processing instructions in the prolog of the XML document. This processing instruction should have a type pseudoattribute with the value text/css and an href pseudoattribute whose value is an absolute or relative URL locating the stylesheet document. For example, this is the processing instruction that attaches the stylesheet in Listing 12-2 (recipe.css) to the file in Example 12-1 (cornbread.xml) if both are found in the same directory.
<?xml-stylesheet type="text/css" href="recipe.css"?>
Including the required type and href pseudoattributes, the xml-stylesheet processing instruction can have up to six pseudoattributes:
screen
tty
tv
projection
handheld
braille
aural
all
By including several xml-stylesheet processing instructions, each pointing to a different stylesheet and each using a different media type, you can make a single document attractive in many different environments.
For example, this group of xml-stylesheet processing instructions could be placed in the prolog of the recipe document to make it more accessible on a broader range of devices:
<?xml-stylesheet type="text/css" href="recipe.css" media="screen" alternate="no" title="For Web Browsers" charset="US-ASCII"?> <?xml-stylesheet type="text/css" href="printable_recipe.css" media="print" alternate="no" title="For Printing" charset="ISO-8859-1"?> <?xml-stylesheet type="text/css" href="big_recipe.css" media="projection" alternate="no" title="For presentations" charset="UTF-8"?> <?xml-stylesheet type="text/css" href="tty_recipe.css" media="tty" alternate="no" title="For Lynx" charset="US-ASCII"?> <?xml-stylesheet type="text/css" href="small_recipe.css" media="handheld" alternate="no" title="For Palm Pilots" charset="US-ASCII"?>
Copyright © 2002 O'Reilly & Associates. All rights reserved.