only-child selector

The :only-child selector applies to elements that are the only element
child of their parent. They can have text siblings, just not element
siblings.

I can't think of any use cases for this, but, I can think of several
for a selector that selects an element that is the only child of it's
parent and /does not/ have any text siblings aside from whitespace.

I want to be able to select

<pre>
<code>
   things like this
</code>
</pre>

but not

<pre>
things like <code>this</code>
</pre>

Can't think of any good names for it (:only-child-content?), but I'd
like to see this in some future version of CSS.

~fantasai

Received on Thursday, 8 March 2007 21:47:48 UTC