W3C home > Mailing lists > Public > www-style@w3.org > January 2010

Re: proposal for a new css combinator

From: Alan Gresley <alan@css-class.com>
Date: Fri, 15 Jan 2010 03:31:11 +1100
Message-ID: <4B4F46CF.6040504@css-class.com>
To: "Tab Atkins Jr." <jackalmage@gmail.com>
CC: Øyvind Stenhaug <oyvinds@opera.com>, www-style list <www-style@w3.org>
Tab Atkins Jr. wrote:
> On Thu, Jan 14, 2010 at 9:24 AM, Øyvind Stenhaug <oyvinds@opera.com> wrote:
>> On Thu, 14 Jan 2010 14:51:16 +0100, Tab Atkins Jr. <jackalmage@gmail.com>
>> wrote:
>>
>>> On Thu, Jan 14, 2010 at 6:41 AM, Alan Gresley <alan@css-class.com> wrote:
>> (...)
>>
(snip)
>> Anyway, syntax-wise a combinator seems more natural than a pseudo-class. I
>> can't think of any other pseudo-class where determining a match depends on
>> what simple selectors there are earlier in the sequence.
> 
> You're right; I knew there was something niggling in the back of my
> brain about it.  Combinators are indeed the way we indicate
> relationships between different parts of the selector; pseudoclasses
> and the like can only tell us special things about the document
> itself, not the selector.  It would be best to maintain that
> distinction.
> 
> ~TJ


I would disagree with you both. Combinator selector have a simple 
relationship between two elements.

<http://www.w3.org/TR/2009/PR-css3-selectors-20091215/#child-combinators>


# A child combinator describes a childhood relationship between
# two elements.


<http://www.w3.org/TR/2009/PR-css3-selectors-20091215/#sibling-combinators>


In the case of sibling selectors, there is also a relationship between 
two sibling elements.

Examples:


div>p

can match the <p> in any example below.

<div>
   <p> .. </p>
</div>

<div>
   <p> .. </p>
   <p> .. </p>
</div>

<div>
   <h1> .. </h1>
   <p> .. </p>
</div>


p+p

can match the second, third, ... <p> in the examples below.

<div>
   <p> .. </p>
   <p> .. </p>
</div>

<div>
   <p> .. </p>
   <p> .. </p>
   <p> .. </p>
</div>


where

h1+p

only matches the first <p> in the examples below. The second , third, 
... <p> will never be matched.

<div>
   <h1> .. </h1>
   <p> .. </p>
   <p> .. </p>
   <p> .. </p>
</div>



Structural pseudo-class are different. :first-child and :last-child 
selects the first or last element of a given type. With Niels Matthijs 
proposal this was for <header> but this could a <p> or a <div>. Unlike 
the structural pseudo-classes of :first-child and :last-child which goes 
across a particular generation of the DOM, :first-descendant and 
:last-descendant would go up or down the tree.



-- 
Alan http://css-class.com/
Received on Thursday, 14 January 2010 16:31:48 GMT

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