W3C home > Mailing lists > Public > www-style@w3.org > August 2010

Re: Difference between CSS21 and Media Queries in parsing media?

From: Bert Bos <bert@w3.org>
Date: Fri, 6 Aug 2010 13:37:13 +0200
To: www-style@w3.org
Message-Id: <201008061337.13609.bert@w3.org>
On Thursday 29 July 2010 16:05:07 Johannes Koch wrote:
> Hi,
>
> in
> <http://www.w3.org/TR/2009/CR-css3-mediaqueries-20090915/#error-handl
>ing> we read:
>
>    Malformed media query. User agents are to handle unexpected tokens
>    encountered while parsing a media query by reading until the end
> of the media query, while observing the rules for matching pairs of
> (), [], {}, "", and '', and correctly handling escapes. Media queries
> with unexpected tokens are ignored. [CSS21]
>
>    @media (example, all,), speech { /* only applicable to speech
> devices */ }
>    @media &test, screen           { /* only applicable to screen
> devices */ }
>
> And a little further down:
>
>    Media queries are expected to follow the error handling rules of
> the host language as well.
>
>
> In
> <http://www.w3.org/TR/2009/CR-CSS2-20090908/syndata.html#parsing-erro
>rs> we read:
>
>    Malformed statements. User agents must handle unexpected tokens
>    encountered while parsing a statement by reading until the end of
> the statement, while observing the rules for matching pairs of (),
> [], {}, "", and '', and correctly handling escapes.

Neither of the two examples above is malformed, so this rule doesn't 
apply.

>
> and in
> <http://www.w3.org/TR/2009/CR-CSS2-20090908/media.html#at-media-rule>
>:
>
>    Invalid statements must be ignored per 4.1.7 "Rule sets,
> declaration blocks, and selectors" and 4.2 "Rules for handling
> parsing errors."

User agents that don't know level 3 of Media Queries will indeed ignore 
both examples as a whole, because of this rule.

But user agents that implement level 3 of Media Queries will ignore a 
smaller part, viz., just the media query that isn't valid in level 3. A 
hypothetical future extension of CSS may still assign a meaning to 
those commas and ampersands.

> Is a CSS 2.1 user agent required to ignore both @media rules quoted
> above "by reading until the end of the statement", while a CSS Media
> Queries user agent will only read "until the end of the media query"
> (ignoring "(example, all,)," and "&test,") and apply the set of
> statements to "speech" (1st @media rule) and "screen" (2nd @media
> rule)?

Yes, that is basically it.



Bert
-- 
  Bert Bos                                ( W 3 C ) http://www.w3.org/
  http://www.w3.org/people/bos                               W3C/ERCIM
  bert@w3.org                             2004 Rt des Lucioles / BP 93
  +33 (0)4 92 38 76 92            06902 Sophia Antipolis Cedex, France
Received on Friday, 6 August 2010 11:37:41 GMT

This archive was generated by hypermail 2.3.1 : Tuesday, 26 March 2013 17:20:30 GMT