[css21 + mediaqueries] Allow media groups in media queries

Currently sect. 7.3.1 of CSS21 defines media groups, that are a set of
keyword to use in the "Applies to" part of property definition, and
maps those groups to media types, to specify what properties UAs must
implement and what features should authors expect from the various
medias.
My proposal is to allow those keywords anywhere a Media Query is
allowed, @media, @import for CSS, but also <?xml-stylesheet?> or
<xhtml:link>.
An example of this is

@media interactive {
strike:hover { text-decoration:line-through; }
}

Use cases:

1) If the above example was slightly more heavy, it could be grouped
in an external @import-ed file. Non interactive UA would then need not
to download it, saving bandwidth.

Example:
@import "complex_visual_effects.css" bitmap;
where complex_visual_effects.css contains hundreds KB of absolute
positioning, background images, transformation matrices...

2) Many media types are both interactive and static, continuous and
paged, grid and bitmap

Example:
@media screen
applies to all types of desktop browsers, in static and interactive
mode; to select only those in interactive mode:
@media interactive

3) Media groups are simple shorthands for multiple media types:

Example:
@media paged is a shorthand for @media print, projection, embossed [,
handheld, tv]

4) Media groups allow forward compatible stylesheets, ie current
stylesheets applied to future media types

Example:
@media audio
would apply to handheld, screen, tv, but also the reader media type,
if it will implemented.

Additional Changes (outside CSS21):

- change media query syntax to:

media_query
 : [ONLY | NOT]? S* media_name S* [ AND S* expression ]*
 | expression [ AND S* expression ]*
 ;
media_type
 : IDENT
 ;
media_group
 : IDENT
 ;
media_name
 : media_type | media_group
;
expression
 : [ '(' S* media_feature S* [':' S* value]? ')' S* ] | media_group |
[ '(' NOT? S* media_group ')' ]
 ;

That is, allow "screen and interactive" or "paged and (not audio)" or
"interactive and (min-color:256)"

Actually, this could be simplified more in:

media_query
 : [ONLY | NOT]? S* expression S* [ AND S* expression ]*
 ;
expression
 : [ '(' S* media_feature S* [':' S* value]? ')' S* ] | '(' NOT?
expression ')' | media_name

This would allow useless things like "screen and handheld" (always
false), but also things like "interactive and (not screen)" or "(not
(color))" (equivalent to "all and (not (color))")

- drop the "grid" media feature
because it is enhanced by the grid media type

As usual, I hope that you'll like these proposals

Giovanni

Received on Monday, 23 February 2009 14:03:15 UTC