Re: [CSS3-page] Headers and Footers on Blank Pages

fantasai wrote:
> 
> Michael Day wrote:
>>
>> Hi fantasai,
>>
>>> A selector for blank pages generated by page breaks would take care
>>> of this.
>>>
>>>   @page :blank {
>>>     visibility: hidden;
>>>   }
>>
>> Prince supports the :blank page class selector, although I think we 
>> would specify "content: none" rather than visibility.
> 
> That would work in the author style sheet, but not in the UA style sheet:
> as soon as the author specifies something else for their margin boxes
> 
>   @page {
>      @top-left { content: "My Header"; }
>   }
> 
> that has overridden the UA's 'content' rules on :blank. (The UA's rule
> is more specific, but it is in a lower level of the cascade.)

I got a request for a better explanation of this off-list, and it was
suggested I post the explanation here, too:

   In the Cascade, the primary sort is by origin.
     1. UA
     2. User
     3. Author
     4. Author !important
     5. User !important

   *within* each level the sort is by specificity. A rule of high specificity
   in the UA style sheet gets overridden by a rule of any specificity in an
   author rule.

   With the above two sets of rules, for a normal page we get (tweaking
   syntax here slightly):

     @page {}
     @top-right { content: "My content." }

   and for a blank page we get:

     @page { visibility: hidden; }
     @top-right { content: "My content." }

   The 'visibility' property inherits, so the final value set of properties
   on @top-right are
     @top-right { visibility: hidden; content: "My content." }
   which means the content takes effect, but the box is invisible.

   If the author wants headers and footers on blank pages, all he has to write is

     @page { visibility: visible; }

   and this will override the UA rule. (@page gets visibility: visible, which then
   inherits into @top-right.)

   So essentially (I've just realized this), we can have this on-off feature in
   CSS3 Paged Media even without introducing :blank. All we have to do is specify
   that blank pages generated by the page break properties are treated as if the
   @page context had a "visibility: hidden" rule. If an author wants the headers
   printed, he just adds
     @page { visibility: visible; }

Melinda Grant wrote (off-list):

> I think I prefer a specific selector for styling blank pages; it would
> provide more flexibility and enable things like the silly blank page
> blurb.

Sure, I think we should add :blank. :) But I also think it would be a good idea
to require in level 3 that the UA have the equivalent of
   @page :blank { visibility: hidden; }
in the UA style sheet. That gives us the functionality we want (ability to turn
headers on and off) without adding :blank, and we can add :blank for additional
styling options in level 4. Plus I think it's a good default. Lets people reuse
the blank pages, if nothing else. ;)

What do you think?

~fantasai

Received on Thursday, 11 October 2007 15:09:01 UTC