HTML and CSS Reference
In-Depth Information
<head>
<title>A Document</title>
<link rel="stylesheet" type="text/css" href="basic.css">
<link rel="alternate stylesheet" title="Classic"
type="text/css" href="oldschool.css">
<link rel="alternate stylesheet" title="Futuristic"
type="text/css" href="3000ad.css">
</head>
As of this writing, most or all known user agents load all linked style sheets, including the
alternate style sheets, regardless of whether the user ever implements them. This can have im-
plications for bandwidth use and server load.
xml-stylesheet processing instruction
In XML documents (such as XHTML documents sent with a mime-type of “text/xml,” “ap-
plication/xml,” or “application/xhtml+xml”), an xml-stylesheet processing instruction can
be used to associate a style sheet with a document. Any xml-stylesheet processing instruc-
tions must be placed in the prolog of an XML document. Multiple xml-stylesheet process-
ing instructions are permitted. The media pseudo-attribute can be used to restrict a style sheet
to one or more forms of media:
<?xml-stylesheet type="text/css" href="basic.css"
media="all"?>
<?xml-stylesheet type="text/css" href="web.css"
media="screen"?>
<?xml-stylesheet type="text/css" href="paper.css"
media="print"?>
It is also possible to link to alternate style sheets with the xml-stylesheet processing instruc-
tion:
<?xml-stylesheet type="text/css" href="basic.css"?>
<?xml-stylesheet alternate="yes" title="Classic"
type="text/css" href="oldschool.css"?>
<?xml-stylesheet alternate="yes" title="Futuristic"
type="text/css" href="3000ad.css"?>
HTTP Link headers
The last (and least common by far) way of associating an external style sheet with your pages
is to use an HTTP Link header. In CSS terms, this is a way of replicating the effects of a link
element using HTTP headers.
Adding a line such as this to the .htaccess file at the root level of your server will make this
happen for all pages on the site:
Search WWH ::




Custom Search