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

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

From: Bert Bos <bert@w3.org>
Date: Thu, 3 Jul 2008 12:04:35 +0200
To: "www-style@w3.org" <www-style@w3.org>
Message-Id: <200807031204.35322.bert@w3.org>

[I added css3-page to the subject line, because it's not really about 
CSS 2.1 anymore.]

On Thursday 03 July 2008 02:41, Grant, Melinda wrote:
> Bert Bos said:
> > On Wednesday 25 June 2008 09:38, Bjoern Hoehrmann wrote:
> > > * Justin Rogers wrote:

> As you may recall, we took the decision here (member-only link):
> http://lists.w3.org/Archives/Member/w3c-css-wg/2007OctDec/0267.html
> and announced it here:
> http://lists.w3.org/Archives/Public/www-style/2007Nov/0119.html.  Per
> my action item, I modified the css3-page grammar to call out
> explicitly that @page is allowed in @media.  (I don't remember
> discussing whether or not to require the semi-colon.)

Those are two different issues, I think. The @page inside @media was 
never a problem, syntax-wise. It's a difference in *semantics* between 
level 2 and level 3 and which has been planned since a long time. The 
CSS 2.1 spec is often not easy to read, but I'm sure that there is 
consensus that, in Justin's original example[1], Firefox's parsing is 
correct and Opera's is not.

The margin boxes inside @page are a different issue. Unlike @media, 
@page was never designed to contain more than declarations. Everything 
that's put inside @page in level 3 thus has to keep on looking like a 
declaration. Which means, concretely, that it has to be separated from 
level 2 features by a semicolon.

[1] 
http://www.w3.org/mid/00BD06E707F60B4F9D6A3E75C712209D53DBA74D41@NA-EXMSG-C104.redmond.corp.microsoft.com


> > There is an alternative proposal, which might be better in
> > light of the fact that those nested @-rules are going to be
> > allowed in level 3. That proposal is to add no
> > clarifications, but change the grammar in appendix G, with
> > the argument that it is in error, because it forbids
> > something that isn't forbidden by any text in the
> > specification. The media rule would then become:
> >
> >     media
> >
> >       : MEDIA_SYM S* medium [ COMMA S* medium ]*
> >
> >         LBRACE S* [ ruleset | media | page ]* '}' S*
> >       ;
> >
> > A potential practical problem is that it would make current
> > implementations that ignore @page inside @media
> > non-conformant and would delay CSS 2.1 until we have
> > sufficient implementations again.
> > (Unless we promise not to test nested @page for now...)
>
> There are at least three shipping implementations that support @page
> inside @media.

That means it's actually possible to relax the grammar in appendix G and 
still exit CR. Hmm, this solution is starting to look better...


> > Is it too late for a different syntax for margin boxes? E.g.,
> > rewriting example V in 3.5.1:
> >
> >     @page ::top-left { ... }
> >     @page ::bottom-center { ... }
> >
> >     @page :left ::left-middle { ... }
> >     @page :right ::right-middle { ... }
> >
> >     @page :left ::bottom-left-corner { ... }
> >     @page :right ::bottom-right-corner { ... }
> >     @page :first ::bottom-left-corner { ... }
> >     @page :first ::bottom-right-corner { ... }

Just for completeness, here is another, shorter syntax. This is what I 
(incorrectly) believed to be in Paged Media:

    @top-left { ... }
    @bottom-center { ... }

    @left-middle :left { ... }
    @right-middle :right { ... }

    @bottom-left-corner :left { ... }
    @bottom-right-corner :right { ... }
    @bottom-left-corner :first { ... }
    @bottom-right-corner :first { ... }


> The nested bracketed syntax for margin boxes has been in this spec
> ever since it was first published nine years ago. It's been through
> several review cycles, including two last calls and a CR.  Several
> implementations have been shipping this for years.  Making radical
> changes now would be very harsh, and I think would send a very
> harmful message.
>
> In my mind, the viable choice is between keeping the requirement for
> the separating semi-colon (and thereby risking having the
> implementations we need) and removing that requirement (which
> apparently leaves us with forward parsing compatibility issues).

I blame myself for not looking at how those margin boxes were actually 
written. My (lame) excuse is that, knowing how much Håkon was 
interested in Paged Media, I didn't need to. I only checked a few 
things in detail, such as that centered boxes were really centered and 
that margin boxes could have multi-line content. :-(

So, if we can't pull margin boxes outside of the @page block anymore, 
then we'll unfortunately have to accept semicolons.

The only way to avoid the semicolons, I think, is to require instead 
that all margin boxes must come *after* all declaration. Thus this is 
wrong:

    @page {
      @top-left {content: "Chapter 1"}   /* WRONG! */
      margin: 0
    }

and this is correct:

    @page {
      margin: 0;
      @top-left {content: "Chapter 1"}
    }



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 Thursday, 3 July 2008 10:05:24 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Monday, 27 April 2009 13:55:10 GMT