Re: At-rules (@-rules) in @media blocks

From: Bjoern Hoehrmann <derhoermi@gmx.net>
Subject: Re: At-rules (@-rules) in @media blocks
Date: Fri, Aug 10, 2001, 11:35 PM

> * Tantek Celik wrote:
>>> It
>>> just says that "a set of rules" is allowed inside an @media block.....
>>> In particular, it seems to me that @page and @font-face rules should be
>>> acceptable in @media blocks.
>>
>>I don't know about "should".  From an implementation/simplicity standpoint,
>>it is better to disallow @-rules inside @media.
>
> They are allowed by the generic syntax in section 4.1.1 of CSS Level 2,
> so the parser propably recognizes them.

No - the parser is supposed to be able to _parse_ them (in case they are
allowed in future levels of CSS), but is certainly not supposed to
_recognize_ them.

> The alternative for @page is, to
> quote myself in news:3c2b246b.109342886@news.bjoern.hoehrmann.de in
> news:comp.infosystems.www.authoring.stylesheets, where this discussion
> was raised:
>
>   | [...]
>   |  @page projection  { size: landscape           }
>   |  @page print       { size: 9cm 18cm            }
>   |
>   |  @media print      { body { page: print      } }
>   |  @media projection { body { page: projection } }
>   | [...]
>
> I won't call that "simple". Even more quoting:
>
>   | [...]
>   |  Not elegant but possible. The alternative is to use external
>   |
>   |    <link media="print"      ... />
>   |    <link media="projection" ... />
>   |
>   |  information.
>   | [...]
>
> That would for the implementation be basically the same thing as
>
>   @media print      { @page { /* ... */ } }
>   @media projection { @page { /* ... */ } }

No no.  Just use media dependent @import and stick the rules in separate
style sheet.  Works fine today for UAs that support @import and @page.

@import "printsheet.css" print;
@import "projsheet.css" projection;

...

/* printsheet.css */
@page { /* ... */ }

...

/* projsheet.css */
@page { /* ... */ }

> So I don't see where forbidding @page in @media makes CSS easier to
> implement

In CSS2, there is no nesting of @-rules at all.  This greatly simplifies
@-rule parsing code.  Parsing something of 1-depth is much easier to code
(read less code, less chance for buggy code etc.) than parsing something of
n-depths.

> or "simpler" for authors :-)

It makes style sheets easier to read.  CSS is supposed to be easy to write
AND read.

If you could nest 15 levels of @-rules, style sheets would begin looking
like C++ files, and I don't think you want that.

Tantek

Received on Saturday, 11 August 2001 12:40:29 UTC