Re: [css3-regions][css3-gcpm] Thoughts on Plan A and Plan B

Håkon Wium Lie:

>  @page :first { columns: 3 }
>  @page { columns: 2 }
> 
>  body::first-page { columns: 3 }
>  body { columns: 2 }
> 
>  @page :first {
>    h1 { color: red }
>  }
> 
>  @page :first {
>    columns: 3;
>    h1 { color: red }
>  }
> 
>  @page :first h1 {
>    color: red
>  }

The selector “@page :first” (at-scope) selects the first physical or logical page in a set. This page has outer properties like physical dimensions (height and width), but it should be a stupid canvas, agnostic of what is painted on it. It’s debatable whether it may be an appropriate multi-column host.

The selector “body::first-page” (pseudo-element) would match the first page that is used for the content of the ‘body’ element, which may or may not be the first page of all the pages for the current document. This page is restricted style-wise in the same way as ‘@page’. 
Like ‘::first-line’ and ‘::first-letter’ this pseudo-element would have to be restricted to the subject of the selector, which in level 3 is the final place in the chain of compound selectors, because it does not exist in the element tree – only in the box tree – and therefore cannot be used to select further descendants. Matching against the box tree is nothing Selectors currently allows.

The selector “body:first-page” (pseudo-class) would match the ‘body’ element (that is all of it and its descendants) if and only if it is completely on the first page of all the pages there are for this document. Sometimes “body *:first-page” or “body>*:first-page” might give the desired result.

What you want instead is a selector to style all parts and descendants (or parts thereof) of a basic selector which will appear on the first page. Since changing their style might make them not appear on this page, there are possible recursions. This makes the design more complicated.

There are basically two syntactic choices that are not counter-intuitive based on how other selectors work:

1.  ‘@page’ <page-name>? <page-pseudo>? <normal-selector>
2.  <pseudo-region> :=
                 ‘:::first-page’
               | ‘:::last-page’
               | ‘:::only-page’
               | ‘:::empty-page’
               | ‘:::nth-page(’ a ‘n’ [ ‘+’ b ]? ‘)’
               | ‘:::nth-last-page(’ a ‘n’ [ ‘+’ b ]? ‘)’

The former variant appears in the quotation as the last suggestion.

The latter variant extends the differentiation between pseudo-classes (1 colon) and pseudo-elements (2 colons) to pseudo-regions or pseudo-pages (3 colons). Like pseudo-classes may apply to pseudo-elements, both may apply to pseudo-regions.

One could replace the three colons by “:on-” to make equivalent pseudo-classes, where naming makes all the difference from the pseudo-class discussed above. I don’t think that’s a good idea, though.

The variant with selectors and rulesets inside an at-block does not work for ‘@page’, because it already has property-value pairs – or descriptors? – directly inside itself. Rules and rulesets shall not appear on the same syntactic level.

The same thoughts apply to regions.

Received on Wednesday, 22 February 2012 13:50:37 UTC