W3C home > Mailing lists > Public > www-style@w3.org > July 2008

Re: [CSS2.1] Grammar for @media versus general block parsing

From: Bert Bos <bert@w3.org>
Date: Wed, 30 Jul 2008 21:13:14 +0200
To: "www-style@w3.org" <www-style@w3.org>
Message-Id: <200807302113.15051.bert@w3.org>

On Wednesday 30 July 2008 10:27, fantasai wrote:
> fantasai wrote:
> > Justin Rogers wrote:
> >> An @media block in the grammar is defined as a MEDIA_SYM followed
> >> by an LBRACE followed by optional rule-sets followed by an RBRACE.
> >> Because @media is a known at-block with pre-defined semantics we
> >> treat the grammar piece as absolute and I think other browsers do
> >> as well, but there is one discrepancy. Here is the test case and
> >> the results. ...
> >> So the question is, should the grammar in this case be read
> >> strictly since it clearly points out a semantic for the @media
> >> block, and thus only allow rule-sets making the Opera/IE 8
> >> behavior correct? Or should the parsers allow any statement within
> >> the block including the at-rule?
> >
> > Recorded as CSS2.1 Issue 62:
> >   http://lists.w3.org/Archives/Public/www-style/2008Jun/0245.html
> >
> > I think we want Firefox's behavior here, as that is
> > forwards-compatible.
> Revised proposal:
>     State in 7.2.1 that "At-rules inside @media are invalid in
>     CSS2.1. Invalid at-rules inside @media blocks must be ignored
>     per 4.2 Rules for handling parsing errors."

The "must ignore" part makes CSS3 UAs non-conformant with CSS 2.1. If 
all UAs implement Paged Media tomorrow (as we want them to do...) then 
we can never make a Rec for CSS 2.1 anymore, because there will be no 
UA that ignores @page inside @media, as required by this proposal.

I think the problems to solve are:

1) CSS 2.1 section 7.2.1 is ambiguous and needs clarification. It says 
the contents of @media is "a set of rules." What are "rules"? Does that 
mean at-rules, rulesets, or both?

2) There is no text that forbids @page from appearing inside @media in 
level 2 style sheets, it is only forbidden by the grammar in appendix 
G. It has to be said in English somewhere.

When section 7.2.1 about @media was first written (in 1997), there was a 
clear dislike of nesting. I think there still is, for reasons of 
usability. But already then we had a Paged Media draft that nested 
@page inside @media. So I think we wanted level 2 style sheets to not 
have at-rules inside at-rules, but without forbidding them for all 

And thus section 7.2.1 should be interpreted as saying that "rules" 
means both at-rules and rulesets. But a level 2 UA is allowed to ignore 
the at-rules.

So here is my cleaned-up version of Fantasai's proposal. Change in 

    a set of rules (delimited by curly braces).
    a set of statements (delimited by curly braces). CSS 2.1 UAs may
    ignore at-rules inside @media blocks. Invalid at-rules must be
    ignored per 4.2 Rules for handling parsing errors.

"Statements" may be hyperlinked to section 4.1.1, for extra clarity.

  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 Wednesday, 30 July 2008 19:14:05 UTC

This archive was generated by hypermail 2.3.1 : Monday, 2 May 2016 14:27:38 UTC