Re: Parent Combinator / Parent pseudo-class

On Jul 25, 2008, at 8:20 AM, Francois Remy wrote:

> From: "Brad Kemper" <brkemper@comcast.net>
>> On Jul 24, 2008, at 10:01 PM, Andrew Fedoniouk wrote:
>>> Second:
>>>
>>> Consider these two selectors:
>>>
>>> p
>>> {
>>>   border: none;
>>> }
>>>
>>> html:with-child(a:hover) p
>>> {
>>>   border: 2em;
>>> }
>>>
>>> and markup:
>>>
>>> <html>
>>> <p><a href="*">sample</a></p>
>>> </html>
>> As far as I can tell, nothing would happen there, because the HTML   
>> element does not have an anchor ("A" element) as a child. It only  
>> has  one as a descendant, and I thought "with-child" referred to  
>> immediate  children only, not grandchildren.
>
> No with-child refers to grandchildren too.
> But it's possible that the name is bad choosen.
>
> Fremy

Well then, I think we should consider single generation version of  
this idea, especially if it will make it faster. Most of the use cases  
involve just children, not all descendants. In fact, I think it would  
be more useful if it had the more limited scope of just immediate  
children.

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. I can really see no use case for a "has-child" pseudo- 
class to look at all descendants.

Received on Friday, 25 July 2008 15:57:48 UTC