On Fri, Jul 25, 2008 at 10:56 AM, Brad Kemper <brkemper@comcast.net> wrote:
>
> Consider the following:
>
> div:with-child(code) { border:2px solid #999; background-color:beige; }
> div:with-child(code):before { content:"See Code:"; }
>
> I would only want this on DIVs that surrounded the Code block directly, not
> on any old DIV that happened to be an ancestor of the code block.
Nod, searching for just children would certainly be useful. That's why my
proposal was for a simple selector preceded by a combinator. You'd do this:
div:matches( > code ) { border:2px solid #999; background-color:beige; }
div:matches( > code ):before { content:"See Code:"; }
I can really see no use case for a "has-child" pseudo-class to look at all
> descendants.
Really? I can. I probably wouldn't ever want to use a plain descendant
selector on something like a plain div, but I could easily see this being
used on a more complex element about which you have a greater knowledge of
it's use. Frex:
div.tab-container:matches( code ) { border:2px solid #999;
background-color:beige; }
<div class="tab-container">
<h1>Tab title</h1>
<div>
Tab body text
<div>
<h1>Code language</h1>
<code> code text </code>
</div>
Tab body text
</div>
</div>
The case for the adjacent-sibling and general-sibling combinators is much
stronger, because it should be *easy* to imagine wanting to key off of a
following sibling (the use cases are exactly anytime you want the opposite
of ~).
~TJ