Re: What implementation is right? (Titled stylesheets)

Mozilla is right, the others are wrong (and I'm not just saying that because I
wrote this part).

This behavior is actually specified quite clearly in the HTML 4.0 spec, see
Section 14.3.2 Specifying external style sheets ( )

The first link (0.css) specifies a persistent style sheet (always applied), the
links titled "First" and "Third" specify preferred style sheets and the link
titled "Second" specifies an alternate style sheet.

The second to last sentence of the relevant section in the HTML spec states:
"If two or more LINK elements specify a preferred style sheet, the first one
takes precedence." so only the style sheet titled "First" should be considered
the author's preferred style sheet.

Furthermore, section 14.3.1 describes how among titled style sheets only those
with the same title are applied at the same time. This clearly shows that the
style sheets "First" and "Third" should _never_ be in use together.

Mozilla treats any preferred style sheets that follow the first specified (by
LINK elements anyhow, it's different with META) as if they are alternate style
sheets. While this is not clearly specified (that I can recall, another
interpretation would be to ignore them competely), it seemed logical at the time.

Once again, thanks to Ian Hickson and his CSS import tests (see ) for making me get all this



Liorean wrote:

> Hello!
> I'm working a bit with alternate stylesheets and a selection mechanism, and
> found a peculiar difference between Mozilla (0.9.9) on one side, and Opera
> (6.01) and Internet Explorer (6.0 for Windows) on the other side. Now I'm
> wondering who handles this correctly, as I couldn't find much about it in
> the CSS, CSS2 or even HTML 4.01 specs.
> Take the following sample HTML code:
> <link type="text/css" href="0.css" rel="Stylesheet">
> <link type="text/css" href="1.css" rel="Stylesheet" title="First">
> <link type="text/css" href="2.css" rel="Alternate Stylesheet" title="Second">
> <link type="text/css" href="3.css" rel="Stylesheet" title="Third">
> Moz renders the untitled stylesheet and the one titled "First", while not
> rendering "Second" or "Third".
> IE and Op render the untitled stylesheet, the one named "First" and
> "Third", while not "Second".
> This proposes some problems as I see it:
> - Stylesheets of more than one title value are rendered at the same time,
> confusing a style select mechanism, especially one that is supposed to
> discern the default ("preferred" in HTML spec) stylesheet.
> - The correct behavior is not expressed in the specs, or at least not
> specified clear enough. (HTML spec mentions preferred stylesheets, but
> doesn't cover multiple preferred title values.)
> - IE and Opera both seem to handle it correctly as I see it, but their way
> is the one that will be hardest to work with.
> If there is no passage handling this case in the specs, I think there
> should be one added to the appropriate specs.
> // Liorean

Received on Sunday, 31 March 2002 15:43:43 UTC