Re: CSS3 missing selector

On Mon, Mar 23, 2009 at 11:39 AM, Eduard Pascual <herenvardo@gmail.com> wrote:
> I'd like to point out that this is a need, rather than a convenience.
> I already gave some explanation of this on my original proposal, but
> to summarize: try to come with a selector that matches any 3rd-level
> heading on a HTML5 document (it is achievable). Once you get it (if
> you get it right), take a look at what you have and think if something
> like :heading(3) or any other direct notation wouldn't make the whole
> language more usable.

FWIW, Eduard is completely correct here.  We *need* a :heading(n)
pseudoclass if we're going to benefit at all from the HTML sectioning
algorithm.

A :section(n) pseudoclass is only slightly less necessary.  This
actually *cannot* be achieved in vanilla CSS, because linear content
can implicitly contain nested sections, and the header which
establishes a section can actually come after the start of the
content.

Frex, in this example, a linear progression of elements creates a
nested series of sections:

<h1>Foo</h1>
<p>foo</p>
<h2>Bar</h2>
<p>bar</p>
<h3>Qux</h3>
<p>qux</p>

The section tree produced is equivalent to the one produced by the following:

<section>
  <h1>Foo</h1>
  <p>foo</p>
  <section>
    <h1>Bar</h1>
    <p>bar</p>
    <section>
      <h1>Qux</h1>
      <p>qux</p>
    </section>
  </section>
</section>

For another example, take this markup:

<section>
  <p>foo</p>
  <h1>Foo</p>
  <p>foo</p>
</section>

The <h1> is the header for the entire section, even though content
precedes it.  Thus, even if you can craft a selector that reliably
selects headers of a particular heading level, you can't use that
selector to then style the contents of the section that header
corresponds to.  A simply "{header} ~ *" won't work, because you have
to hit previous content as well.

There are some problems with the :section() pseudoclass, though.
Namely, it can't decide whether it wants to be a pseudoclass or a
pseudoelement.  To be precise, it's *logically unable* to decide that,
because sometimes it has to be a pseudoclass (when an explicit
<section> element exists), and sometimes it has to be a pseudoelement
(when sectioning is implicit).  I'm not sure whether this will be a
significant issue in implementation or not.

~TJ

Received on Monday, 23 March 2009 17:31:50 UTC