W3C home > Mailing lists > Public > www-style@w3.org > March 2009

Re: CSS3 missing selector

From: Giovanni Campagna <scampa.giovanni@gmail.com>
Date: Mon, 23 Mar 2009 14:15:24 +0100
Message-ID: <65307430903230615o1841520dnbaf860fb310e3f7e@mail.gmail.com>
To: Dave Smith <smithd7@tcd.ie>
Cc: www-style@w3.org
2009/3/23 Dave Smith <smithd7@tcd.ie>:
> Hi www-style
>
> I believe there is a useful and yet missing selector. I'll explain by a
> rough example:
>
> <section>
> <h1 or h>My section heading</h1 or h>
> <p>Para</p>
> <p>Para</p>
> <p>Para</p>
> <p>Para</p>
> </section>
>
> Given the above, to style the section content so that it is indented by
> 20px, but leave the heading with no margin can be done with:
>
> ..section > *:not(h1) {margin-left:20px;}

You could also use ".section > p"

(or negative margins, or text-indent, but this is not relevant to the selector)

> but what if the following could be done:
>
> h1:content {margin-left:20px;}
> A pseudo element wraps the content, based on heading scope, and is then
> styled.
>
> and
>
> h1:section { }
> A pseudo element wraps the heading and content, based on heading scope, and
> is then styled.

1) Pseudo-elements use two colons: "::section" and "::content"
2) It should always be avoided having pseudo-elements targeting real
elements (instead of CSS generated ones)
3) Something similar to this was already proposed [1]:

:heading(<level>)
pseudo-class to select elements that estabilish an heading at that
level (according to the relative language)

:section(<level>)
pseudo-class to select elements that estabilish a section at that
level (according to the relative language)

For example, :heading(2) matches "h2" or  "section > section > h" in XHTML2
:section(1) matches "body" in HTML5

> Apart from being easy to read, one possible advantage is in backwards
> compatibility with old documents (without section elements) that they could
> be styled just as easily as new ones. Plus it just feels good, at least to
> me.

Well, old documents don't use new features, so they won''t get much
benefits from this.

> all the best
> Dave
> ---
> Dave Smith, 01 896 3976, smithd7@tcd.ie, Trinity Web Office
> Please CC the Web Office, webdes@tcd.ie, in correspondence
> Please note that electronic mail to, from, or within the College may be the
> subject of a request under the Freedom of information Act
>

Anyway, Selectors Level 3 is currently a Last Call WD, so new features
won't be accepted. You should wait until Selectors Level 4.

Giovanni

[1] http://lists.w3.org/Archives/Public/www-style/2008Nov/0453.html
Received on Monday, 23 March 2009 13:15:58 GMT

This archive was generated by hypermail 2.3.1 : Tuesday, 26 March 2013 17:20:17 GMT