W3C home > Mailing lists > Public > www-style@w3.org > February 2014

Re: A *:body pseudo class

From: Tab Atkins Jr. <jackalmage@gmail.com>
Date: Fri, 31 Jan 2014 20:53:57 -0800
Message-ID: <CAAWBYDBzokaHbVTfyd46VOAT_81e9rwZY7CX2nFNcx55Jor9+w@mail.gmail.com>
To: Leif Halvard Silli <xn--mlform-iua@xn--mlform-iua.no>
Cc: www-style list <www-style@w3.org>
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

This archive was generated by hypermail 2.3.1 : Monday, 2 May 2016 14:39:18 UTC