Re: Alternate style sheets in CSS3.

William,

Very interesting.  You essentially came up with the same syntax for
@alternate that I did, although I only posted my proposal to CSS & HTML
WG-only lists:

 http://lists.w3.org/Archives/Member/w3c-css-wg/2003AprJun/0308.html

 http://lists.w3.org/Archives/Member/w3c-html-wg/2003AprJun/0453.html

I've included the text from my message below demarcated by ==============.

I believe the incorporation of "@alternate" and the additions to "@import"
is in progress for the CSS3 Cascade module.

Thanks,

Tantek

On 6/11/03 9:21 AM, "Tantek Çelik" <tantek@cs.stanford.edu> wrote:

==============

Note: when I say "media types" I mean _media_ (screen, print, tv etc.)
types, not the renamed "mime types".


It is not clear to me that the set of alternate style sheets belongs in
markup at all.


Concept:

Consider a collection of documents on a site which all use the same style
sheet.  Rather than placing the style sheet inline into each document using
<style> elements, it makes much more sense to place the style sheet into a
single external location and use a single <link rel='stylesheet'> to refer
to it.  

This way it is much easier to make style changes in one place and have them
immediately reflected in the collection of documents, rather than having to
edit/save each and every document in the collection in order to provide new
styling.

The same analogy can be made with the "set of alternate style sheets".
Rather than placing the set of alternate style sheets into each document
using numerous <link> elements (or PIs, or the alternatives proposed), it
makes much more sense to place the set of alternate style sheets into a
single external location, and use a single <link> (or PI or some other
means) to refer to the whole set.

This way it is much easier to make changes to the set of alternates (e.g.
add another alternate for a new media type, e.g. handheld, print etc.) in
one place and have them immediately reflected in the collection of
documents, rather than having to edit/save each and every document in the
collection in order to provide the alternate presentation(s).


Possible syntax:


There are a couple of fairly obvious ways that CSS could be extended to
provide this external alternates functionality.


1. @import extension

Currently @import rules refer to a URI and an optional list of media types.

@import "foo.css" screen,tv;

This syntax can easily be extended to allow an additional optional alternate
name string on the end, e.g.

@import "big.css" screen,tv "Large Fonts";

would add the style sheet "big.css" to the alternate group titled "Large
Fonts".


2. @alternate new at-keyword.

A new keyword, @alternate could be introduced to allow specific style rules
to be cascaded when an alternate group was selected, e.g.:

@alternate "Large Fonts"
{
  body,td,p { font-size:x-large }
  h1 { font-size:200% }
  /* etc. */
}

would cause the contained rules to be cascaded as part of the containing
style sheet when the alternate group titled "Large Fonts" was chosen by the
user.  This is similar to how the @media rule allows the contained rules to
be cascaded as part of the containing style sheet when particular medium is
being rendered.

I believe these two mechanisms would be sufficient to supercede the
alternate style sheets mechanism offered in HTML4.01, and more over, provide
an alternate style sheets mechanism for *any* XML document, not just
(X)HTML.

Tantek

...


==============


On 2/21/04 9:25 AM, "William Birchenough" <bircheno@apk.net> wrote:

> 
> 
> 
> Greetings!
> 
> 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
> form:
> 
> @preferred
> {
> /* 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!
> 
> Bill
> 
> References:
> [1]    For the HTML4 discussion of external style sheets, including
"preferred"
> and "alternate" style sheets:
> 
> http://www.w3.org/TR/REC-html40/present/styles.html#h-14.3
> 
> [2]    An earlier proposal:
> http://lists.w3.org/Archives/Public/www-style/2002Oct/0049.html
> 
> [3]    The response to the earlier proposal:
> http://lists.w3.org/Archives/Public/www-style/2002Oct/0058.html
> 
> --
> Bill Birchenough
> bircheno@apk.net
> 

Received on Saturday, 21 February 2004 17:28:43 UTC