Re: [css-book] Re: [css-page] Meaning of :first page selector (was: [css3-gcpm] Page groups, named pages, and :first)

On Tue, Oct 22, 2013 at 10:38 AM, Håkon Wium Lie <howcome@opera.com> wrote:
> Also sprach Tab Atkins Jr.:
>
>  > > To me, it seem quite intuitive that
>  > >
>  > >    @page :nth(1) { ... }
>  > >
>  > > selects the first page and that
>  > >
>  > >    @page funky:nth(1) { ... }
>  > >
>  > > selects the first page of the "funky" group
>  > >
>  > > I don't see a need for further syntactic differentiations. Also, this
>  > > has been implemented and used for years.
>  >
>  > That's not how selectors work.
>
> But it's how psedo-elements work. This "selector":
>
>   p:first-line
>
> selects the first line of every p element (by creating a
> pseudo-element etc).

That's because pseudo-elements hide a combinator in their syntax. The
syntax parallels between pseudo-elements and pseudo-classes has long
been a source of confusion for web authors, and occasionally for spec
writers.  The two really have nothing to do with each other, and it
would have been much better had it been an explicit combinator into
the "pseudo-children" of the element.

> Likewise, this selector:
>
>   @page funky:nth(2)
>
> should give us the second page of every funky page group.
>
> Thinking of it as pseduo-elements may make it easier to extend into:
>
>   @page funky:nth(2) p
>
> Where all p elements inside those pseud-elements are selected.

If ::nth() is a pseudo-element, that's fine.  If it's a pseudo-class,
it's not fine.  You're free to choose which way it works, but the
syntax needs to match up properly - double colons for pseudo-elements.

However, I don't think that ::nth() as a pseudo-element works.  You're
still styling the page, not some other construct created by the
browser.  It's just filtering, like a normal selector, and so is most
like a pseudo-class.

If some printer implementations have done this wrong, whatever, but
don't infect the rest of the platform with inconsistent semantics in
their selectors.  If you want the second funky page, use

@page :nth-match(2 of funky) { ... }

~TJ

Received on Tuesday, 22 October 2013 17:02:07 UTC