Re: New ::first-page pseudo-element

On Tue, Oct 25, 2011 at 03:58:30PM +0200, Håkon Wium Lie wrote:
> Michael Day wrote:
> 
>  > We've had user requests for the ability to switch from one column layout 
>  > on the first page, to two column layout on the second and subsequent pages.
>  > 
>  > To achieve this we have implemented a new ::first-page pseudo-element, 
>  > similar to the existing ::first-line pseudo-element, that can be used to 
>  > adjust a subset of CSS properties for an element on the first page that 
>  > it appears. 
> 
> This seems like a natural new member in the family of pseudo-elements. 

There are a couple of details in which it might differ from,
i.e. might not be a completely natural addition to, the existing
first-line/first-letter pseudo-elements.

One of the unresolved issues with ::first-letter and ::first-line was
whether they create a new element, or merely change properties of glyphs
falling within the first letter/line, or something in between.

For the use case given (an element that has two columns except on its
first page), the proposed ::first-page pseudo-element requires a
particular answer to that question: in must modify properties of the
box(es) of the element that fall on the element's first page, it cannot
involve creating a new element/box as either parent or child of the
element's first-page box(es).  So whether ::first-page is a natural
addition in this respect depends on how this ::first-line/::first-letter
issue gets resolved.


An intereresting characteristic of ::first-letter is that it only selects
the first letter "of the first line of a block": if the block begins with
punctuation wide enough to push the first actual letter to the second line,
then ::first-letter selects nothing.  [UAs vary in their behaviour in this
situation, but that's at least my reading of what the spec requires.]
This choice of edge-case behaviour slightly simplifies implementation
because one is guaranteed that what's selected by ::first-letter is a
subset of what's selected by any ::first-line selector.  (Thus for
example there's no splitting of first-letter across lines, and the
determination of inherited property values doesn't need to provide for
this rare case that there's something that inherits from first-letter
but not whatever first-line rules are requested.)

One might then wonder whether the first line should similarly only match
within the first page of the element.  So there's a choice between either
being inconsistent with the first-letter ⊆ first-line approach, or
introducing a subtle change in the behaviour of the ::first-line and
::first-letter selectors (namely that they only match within the first
page: which in practice is almost always, but nevertheless it would be a
change).


I note that @page selectors can already change the number of columns
displayed on the :first page, for example by changing the available width
on that page and hence how many column-width & column-gap fit on that
page.  This makes me wonder whether we ought to add column-related
properties to the set of properties that apply in the @page context
(section 7 of css3-page).  That doesn't cover all the use cases that
::first-page could be put to, but it is a possibility that we can
consider when deciding how ::first-page should behave or what priority
to give to working on its specification and implementation.

pjrm.

Received on Wednesday, 26 October 2011 00:55:10 UTC