- From: L. David Baron <dbaron@dbaron.org>
- Date: Fri, 7 Mar 2008 20:46:26 -0800
- To: Justin Rogers <justrog@microsoft.com>
- Cc: "www-style@w3.org" <www-style@w3.org>
On Saturday 2008-01-26 16:58 -0800, Justin Rogers wrote: > > > Browsers are inconsistent here. > > > How? > > > I've given an example below. I've messed up two charset rules supplied > a bogus page and media, given a valid import (a.css which is DIV { > color: purple }), followed by an invalid one, followed by another > valid one (c.css which is DIV { color: green; })... Sorry to have dropped this one on the floor for a while. > @charset "utf-8" foo bar baz; > @charset "utf-8" foo bar baz; > @page { } > @media { } > @import url(a.css); > @import url(b.css) foo bar; > @import url(c.css); There's a problem with your example. The @page rule in it is actually perfectly valid. Therefore any browser that supports @page should pretty clearly ignore the @import rules based on the current spec. So I'm not sure there's as much of an inconsistency as you thought. Compare the following: http://dbaron.org/css/test/2008/import-after-page http://dbaron.org/css/test/2008/import-after-pagg http://dbaron.org/css/test/2008/import-after-media In Firefox, the first two are green, since @page is not supported or parsed. But the third is black and underlined. The same is true of IE7. This means the ignored @page and @pagg rules are not used to determine whether to ignore the @import, but the used @media rule is. In Opera 9.26, the one with @page is black (@import ignored), but the one with @pagg is green (@import used). This makes sense since @page is supported in Opera. In Safari 3.0.4, all three are black (so there is some inconsistency). I don't think any clarification to the spec is strictly needed, since http://www.w3.org/TR/2007/CR-CSS21-20070719/syndata.html#at-rules says: # CSS 2.1 user agents must ignore any '@import' rule that occurs # inside a block or after any valid statement other than an @charset # or an @import rule. Note the "any *valid* statement". This requirement is a conformance requirement on user agents. However, there is the statement at http://www.w3.org/TR/2007/CR-CSS21-20070719/cascade.html#at-import (which you quoted in the first message in this thread): # Any @import rules must precede all other rules (except the @charset # rule, if present). which is a conformance requirement on style sheets. Perhaps to make this clearer, we should add "In CSS 2.1," or "In valid CSS 2.1 style sheets," to the beginning of the sentence. We could also add an additional sentence following it saying: # See the <a href="syndata.html#at-rules">section on parsing</a> for # when user agents must ignore @import rules. -David -- L. David Baron http://dbaron.org/ Mozilla Corporation http://www.mozilla.com/
Received on Saturday, 8 March 2008 04:46:36 UTC