W3C home > Mailing lists > Public > www-style@w3.org > February 2004

Alternate style sheets in CSS3.

From: William Birchenough <bircheno@apk.net>
Date: Sat, 21 Feb 2004 12:25:13 -0500 (EST)
Message-ID: <403795DE.7388C32@apk.net>
To: www-style@w3.org


An HTML4 feature that I use is the notion of preferred, persistent, and
alternate style sheets [1].  Unfortunately, there are three drawbacks to the
HTML4 approach.  First, every document that I write with alternate stylesheets
must include the same (sometimes lengthy) block of LINK elements; if I want to
add a new alternate style, then I have to modify all documents which use these
styles.  Second, there is no way to group together small variations, so I need
a separate CSS file for every alternate style sheet.  Third, the approach only
works with HTML4 and its XHTML descendents, not with more general XML.

I have two examples of situations where a slight variation in style is useful.
First, consider two style sheets which differ only in the base font style, with
the second allowing users with weak vision to see a larger font.  Second,
consider a quiz, for which the answers should be invisible when printing unless
the "Teacher" alternate style has been selected.

Therefore, I would propose a pair of a new @-rules to allow alternate styles
within a single stylesheet.  Roughly speaking, they would have the following

		/* Ruleset. */

	@alternate ruleset-title
		/* Ruleset. */

Note that any styles not enclosed in a @preferred or @alternate block would
be persistent styles, so there is no need for a @persistent block.

Also note that if the ruleset includes a @media block, then this achieves the
same functionality as the media attribute in the LINK element.

The "ruleset-title" is a string (wrapped in quotes if it includes spaces,
just like a font family) which the user agent may display to the user to allow
the user to select the block.  It corresponds to the use of the "title"
attribute in the LINK element.

Unless the user indicates otherwise, the user agent should apply the styles in
the @preferred block.  User agents should allow the user to select among the
alternate styles as well.  If an alternate style is selected, styles from other
@alternate blocks and @preferred blocks should not be displayed.

My proposal differs from an earlier proposal [2] in that the earlier proposal
suggested a means to import alternate style sheets, more similar to the HTML4
LINK element.  There was only response [3], which objected to the complexity of
interpretation across multiple optional stylesheets and the lack of backwards
compatibility.  I don't believe my proposal is any more complicated than the
current use of @media.  However, the lack of backwards compatibility--because
current browsers would skip the @alternate rule (which is good) but also the
@preferred rule (which is not so good)--remains an issue.

Hopefully, since the CSS Selectors module is still a working draft, my proposal
will receive consideration.  Thanks!


[1]	For the HTML4 discussion of external style sheets, including "preferred"
	and "alternate" style sheets:


[2]	An earlier proposal:

[3]	The response to the earlier proposal:

Bill Birchenough
Received on Saturday, 21 February 2004 16:50:52 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Monday, 27 April 2009 13:54:26 GMT