Re: [css3-mediaqueries] Syntax connecting MQ to CSS 2.1

On Friday 24 July 2009, Anne van Kesteren wrote:
> On Wed, 01 Jul 2009 00:16:24 +0200, L. David Baron <dbaron@dbaron.org> 
wrote:
> > On Thursday 2009-06-11 19:06 +0200, Øyvind Stenhaug wrote:
> >> The Media Queries syntax section[1] says that "The
> >> media_query_list production defined below replaces the medium
> >> production from CSS2". However, according to the grammar in the
> >> latter document[2] a media rule may contain a comma-separated list
> >> of 'medium' tokens. My interpretation is that one would then end
> >> up with something like this:
> >
> > Yeah, this seems wrong.
>
> Agreed.
>
> > One possible fix would be to say that for CSS usage of media
> > queries, the "media_query" production replaces the "medium"
> > production from CSS 2.1.  This would mean that "@media {}" would be
> > invalid.  This would leave the "media_query_list" production to be
> > used only by other specifications.
> >
> > I think the next easiest change would be to make an editorial
> > change to CSS 2.1, and add another production:
> >   media_list
> >
> >     : medium [ COMMA S* medium ]
> >
> >     ;
> > and then change both the "import" and "media" productions to
> > reference media_list instead of writing out the above syntax by
> > hand in both places.  Then css-mediaqueries could says that
> > media_query_list replaces media_list.  This would mean that "@media
> > {}" is valid.
> >
> > For what it's worth, Gecko accepts "@media {}" (as meaning the same
> > as "@media all {}").  (I think it has since I implemented media
> > queries, but didn't before.)
>
> I'm ok either way though allowing @media {} would give consistency
> with media="" from HTML (and was the intention, admittedly).

1) About omitting the media query from @media:

CSS2 allows to omit the media from @import but not from @media. That is 
deliberate, because

    @import "foo"

has an obvious meaning, while

    @media {<rules>}

would be confusing and redundant. It would either mean the same 
as "<rules>" by itself or be ignored completely.

If at all possible, I'd like to avoid (a) changing the CSS2 
specification and (b) introducing syntax that is confusing.



2) About how the media queries syntax hooks into CSS2 syntax:

2a) The easiest solution seems to be to remove the "media_query_list" 
production. The text in section 3 above the grammar would then 
say: "The media_query<del>_list</del> production defined below replaces 
the medium production from CSS2."

That also takes care of (1) above.

Disadvantage: specifications (such as HTML) that also want to use media 
queries, and that want a comma-separated list of them, will have to 
define the syntax of the comma-separated list themselves.

2b) Alternatively, we can rewrite the grammar in appendix G of CSS2 to 
introduce a non-terminal "media_query_list." This is a bit more work, 
but it can be done, because it is only editorial. The rules 
for "import" and "media" would be rewritten in terms of the 
new "media_query_list" non-terminal as:

    import
      : IMPORT_SYM S*
        [STRING|URI] S* media_query_list? ';' S*
      ;
    media
      : MEDIA_SYM S* media_query_list LBRACE S* ruleset* '}' S*
      ;
    media_query_list
      : medium [ COMMA S* medium]*
      ;



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 Monday, 3 August 2009 14:12:26 UTC