Re: A *:body pseudo class

On Thu, Jan 30, 2014 at 9:35 PM, Leif Halvard Silli
<xn--mlform-iua@xn--mlform-iua.no> wrote:
> This might well have been thought of already. But when
> designing/styling some HTML documents as a book, I found myself
> repeatedly adding div elements of the following kind:
>
> <section>
>  <h1> Headding</h1>
>  <div class="body-text">
>    <p>Lorem
>    <p>Ipsum
>    <p>Dolor
>    <p>Sint
>  </div>
> </section>
>
> The point was to be able to style the body independently from the
> heading. For instance, I wanted a border around the body. And I wanted
> the body - but not the heading - to be split in columns. Etc.
>
> Given that it ought to be a universal pattern that body text follows
> *after* headings, I am hereby proposing a *:body pseudo class.
>
> The :body pseudo class should select all non-heading content inside a
> particular element. And its purpose should be to avoid that authors
> have use div elements in order to make such sections selectable and
> stylable.
>
> (I say ”and stylable” because pseudo classes are (in)famous for not
> allows as much styling as ”real” HTML classes. Think :link and
> :first-line, for instance.)

You're thinking of a pseudo-element, not a pseudo-class.  (And are
experiencing some confusion about which is which, too - :link is a
pseudo-class, ::first-line is a pseudo-element.)

Pseudo-classes are magic classes auto-added by the UA.  They're
filters for existing elements, just like ordinary classes.

Pseudo-elements are magic elements auto-added by the UA.  They may be
brand-new, like ::before and ::after, or wrapped around existing
content, like ::first-line.

Headings are not universally the first element in their parent, so
this proposed pseudo-element would have to generate as two elements,
one wrapping content before the heading and the other wrapping content
after.

I think it's best just to use an explicit element for this, which
already exists in the form of <main>, as Ted explained.

~TJ

Received on Saturday, 1 February 2014 04:54:45 UTC