Alternate style sheets are supported in most Gecko-based browsers like Mozilla and Netscape 6+, and in Opera 7.
They can be supported in Internet Explorer through the use of JavaScript but are not natively supported by those
browsers.
It is also possible to group alternate style sheets together by giving them the same title value. Thus, you make it possible for the user to pick a
different presentation for your site in both screen and print media. For example:
<link rel="stylesheet" type="text/css"
href="sheet1.css" title="Default" media="screen" />
<link rel="stylesheet" type="text/css"
href="print-sheet1.css" title="Default" media="print" />
<link rel="alternate stylesheet" type="text/css"
href="bigtext.css" title="Big Text" media="screen" />
<link rel="alternate stylesheet" type="text/css"
href="print-bigtext.css" title="Big Text" media="print" />
If a user selects "Big Text" from the alternate style sheet selection mechanism in a conforming user agent, then bigtext.css will be used to style the
document in the screen medium, and print-bigtext.css will be used in the print medium. Neither sheet1.css nor print-sheet1.css will be used in any
medium.
Why is that? Because if you give a link with a rel of stylesheet a title, then you are designating that style sheet as a preferred style
sheet. This means that its use is preferred to alternate style sheets, and it will be used when the document is first displayed. Once you select an
alternate style sheet, however, the preferred style sheet will not be used.
Furthermore, if you designate a number of style sheets as preferred, then all but one of them will be ignored. Consider:
<link rel="stylesheet" type="text/css"
href="sheet1.css" title="Default layout" />
<link rel="stylesheet" type="text/css"
href="sheet2.css" title="Default text sizes" />
<link rel="stylesheet" type="text/css"
href="sheet3.css" title="Default colors" />
All three link elements now refer to preferred style sheets, thanks to the presence of a title attribute on all three, but only one of them will
actually be used in that manner. The other two will be ignored completely. Which two? There's no way to be certain, as neither HTML nor XHTML
provide a method of determining which preferred style sheets should be ignored or which should be used.
If you simply don't give a stylesheet a title, then it becomes a persistent style sheet and is always used in the display of the document.
Often, this is exactly what an author wants.
1.4.2 The style Element
The style element, which is a new element in HTML, is the most common way to define a style sheet, since it appears in the document itself:
<style type="text/css">
style should always use the attribute type; in the case of a CSS document, the correct value is "text/css", just as it was with the link
element.
The style element should always start with <style type="text/css">, as shown in the preceding example. This is followed by
one or more styles and is finished with a closing </style> tag. It is also possible to give the style element a media attribute, with the
same allowed values as previously discussed for linked style sheets.
The styles between the opening and closing style tags are referred to as the document style sheet or the embedded style sheet since this style sheet
is embedded within the document. It will contain many of the styles that will apply to the document, but it can also contain multiple links to external
style sheets using the @import directive.