Alternative style sheets
Specifying alternative style sheets in a web page provides a way for users to see multiple versions of a page, based on their needs or preferences.
This feature is not well supported in browsers without an extension. To offer alternative presentations that work with a user's existing preferences, see the CSS media features
Firefox lets the user select the stylesheet using the View > Page Style submenu. Other browsers require an extension to enable this functionality. The web page can also provide its own user interface to let the user switch styles.
The alternate stylesheets are commonly specified using a
<link> element with
rel="alternate stylesheet" and
title="..." attributes. For example:
<link href="reset.css" rel="stylesheet" type="text/css"> <link href="default.css" rel="stylesheet" type="text/css" title="Default Style"> <link href="fancy.css" rel="alternate stylesheet" type="text/css" title="Fancy"> <link href="basic.css" rel="alternate stylesheet" type="text/css" title="Basic">
In this example, the styles "Default Style", "Fancy", and "Basic" will be listed in the Page Style submenu, with "Default Style" pre-selected. When the user selects a different style, the page will immediately be re-rendered using that style sheet.
No matter what style is selected, the rules from the reset.css stylesheet will always be applied.
Any stylesheet in a document falls into one of the following categories:
- Persistent (no
title=""): always applies to the document.
- Preferred (no
title="..."specified): applied by default, but disabled if an alternate stylesheet is selected. There can only be one preferred stylesheet, so providing stylesheets with different title attributes will cause some of them to be ignored.
- Alternate (
title="..."must be specified): disabled by default, can be selected.
When style sheets are referenced with a
title attribute on the <link rel="stylesheet"> or
<style> element, the title becomes one of the choices offered to the user. Style sheets linked with the same
title are part of the same choice. Style sheets linked without a
title attribute are always applied.
rel="stylesheet" to link to the default style, and
rel="alternate stylesheet" to link to alternative style sheets. This tells the browser which style sheet title should be selected by default, and makes that default selection apply in browsers that do not support alternate style sheets.
BCD tables only load in the browser