Cascading Style Sheets/Applying CSS to XML

From Wikibooks, open books for an open world
Jump to navigation Jump to search

To apply a stylesheet to an XML document, place the modified following example into the prolog of the XML document.

 <?xml-stylesheet href="style.css" type="text/css"?>

Any XML declaration, such as <?xml version="1.0" encoding="UTF-8"?>, must precede the stylesheet processing instruction.

This applies to XHTML too, if it is served with the correct MIME type: application/xhtml+xml.

A complete example, with an XML declaration and a stylesheet processing instruction:

<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet href="rss_style.css" type="text/css"?>
<rss version="2.0">
    <title>My news feed</title>
    <description>Latest news</description>
    <pubDate>Wed, 06 Sep 2006 00:00:00 GMT</pubDate>


[edit | edit source]