Do you have a question? Post it now! No Registration Necessary. Now with pictures!
- Posted on
- Persistent, default and alternate styles
- Eric Lindsay
December 21, 2005, 4:40 pm
rate this thread
I am trying to understand the differences between and uses of
persistent, default and alternate styles. I have read
http://www.w3.org/TR/REC-html40/present/styles.html section 14.3.2 on
specifying external style sheets in link using combinations of rel and
using or not using the title attribute.
I think I sort of understand rel="alternate stylesheet". It seems to be
able to act something like the media="print" or media="handheld" or
media="projection" Except it does not act automatically to produce the
layout as defined. Instead, the user agent has to support it, and the
user has to select the alternate style sheet. I can't find access in
Safari. In Firefox, Page Style. In Opera, View, Style, and then a list
of the Title given to each of the style sheets in the link to them.
However the reference above says to name the alternate style sheet using
the title attribute. Whereas at
http://www.w3.org/TR/2002/CR-css3-mediaqueries-20020708/ there are
examples of links to them without title attributes. So is it required
or not? I would think it is required. I think this is supported by the
use of title to indicate the difference between persistent and preferred
Moving to persistent vs preferred style sheets, most style sheets seem
to be persistent. That is, the link has href="mystyle.css"
rel="stylesheet" type="text/css" However most do not include the
title="whatever", so they are not preferred style sheets. So am I right
in thinking a persistent style sheet is used when you expect that other
style sheets (or styles) may also be used by the HTML document. And a
preferred style sheet would be appropriate where you think it may be
replaced entirely by some other style sheet?
Re: Persistent, default and alternate styles
Eric Lindsay wrote:
There's a good text on this at
http://www.alistapart.com/articles/alternate/ (At least, the use of
alternate stylesheets is explained quite clearly, I'll ignore the
merits or shortcomings of the proposed JS).
Yes, you're right.
* Use a persistent stylesheet for style rules that you want to see
applied at all times.
* Use a preferred stylesheet for style rules that go on top of the
persistent style, and that you propose as a default, but may be changed
when the user selects one of the alternate stylesheets.
* Use alternate stylesheets for styles that can replace the style given
in the preferred stylesheet.
You could imagine having a persistent stylesheet that describes the
general layout of your page, a preferred stylesheet that declares
colours and background images, and an alternate stylesheet that uses
black and white only, and puts borders on certain elements. Note that
you can break up one persistent, preferred or alternate "stylesheet"
into several css files, provided you give them the same title.
<link rel="stylesheet" type="text/css" href="basiclayout.css" />
<link rel="stylesheet" type="text/css" href="basicfonts.css" />
<link rel="stylesheet" type="text/css" href="fancycolours.css"
<link rel="stylesheet" type="text/css" href="fancybackgrounds.css"
<link rel="alternate stylesheet" type="text/css" href="b-w.css"
<link rel="alternate stylesheet" type="text/css" href="borders.css"
I'm not sure how alternate stylesheets are supposed to interact with
stylesheets for different media, nor how they do interact in reality.
I'd guess that the UA that is about to print a page would look only at
the stylesheet links with the applicable media attributes ("print" or
"all"), and determine which of these are persistent, preferred or
Garmt de Vries.