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

Re: Specificity: nth-of-type versus attribute selector?

From: Estelle Weyl <estelle@weyl.org>
Date: Sun, 4 Jul 2010 12:49:57 -0700
Cc: www-style@w3.org, "L. David Baron" <dbaron@dbaron.org>
Message-Id: <5CD9F325-461C-419A-A6A6-41E694FBEDDC@weyl.org>
To: Anton Prowse <prowse@moonhenge.net>

On Jul 4, 2010, at 9:32 AM, Anton Prowse wrote:

> L. David Baron wrote:
>> On Sunday 2010-07-04 10:24 +0200, Anton Prowse wrote:
>>> "Specificity" isn't the right term here (it has another meaning in  
>>> CSS
>>> Selectors [3]) but I understand what you're asking.  However,  
>>> there is
>>> no universal common behaviour of pseudo-classes as regards their
>>> interaction with other parts of the sequence of simple selectors to
>>> which they belong.
>>> Hence we must turn to the definition of the :not pseudo-class to
>>> discover its behaviour:
>>> "The negation pseudo-class, :not(X), is a functional notation  
>>> taking a
>>> simple selector (excluding the negation pseudo-class itself) as an
>>> argument. It represents an element that is not represented by its
>>> argument."[4]
>>> So, in the sense you mean, the :not pseudo-class does behave  
>>> differently
>>> from the :nth-of-type pseudo-class in that the whole of the simple
>>> selector argument is taken into consideration.
>> I think this is a confusing way to describe things.  I think it's
>> clearer to simply say that the parts of the simple selector are
>> independent of each other, and then the results are combined.  Thus:
>>  :nth-of-type(5) selects any p element that is the fifth p element
>>  within its parent, any div element that is the fifth div element
>>  within its parent, any i element that is the fifth i element
>>  within its parent, etc.
>>  p selects any p element.
>>  p:nth-of-type(5) selects the intersection of those two sets, which
>>  is any p element that is the fifth p element within its parent.
>> Thus, if you add attribute selectors to the same simple selector,
>> you're not changing what :nth-of-type() means, you're just
>> intersecting the result with an additional restriction.
> Yes, I fully agree that intersection is the right way to view this  
> (and
> was planning to say so should Estelle have replied; this formulation
> only occurred to me seconds after pressing Send ;-)
> img[src*="photo"]:nth-of-type(odd)
> is the set of elements E which satisfy all of the following  
> properties:
> E is an img element
> E has a src attribute whose value features the substring "photo"
> E is the first or third or fifth or ... element of its type (ie img)  
> of
> its parent.
> But what I was trying to emphasize in my comment is that :not is in  
> some
> sense more powerful than nth-of-type pseudo-class.  If nth-of-type was
> renamed slightly (nth-of-specialized-kind ?!) and took a simple  
> selector
> as an argument as well as the an+b notation, then it would behave a  
> bit
> more like :not (as well as addressing the problem which I think  
> Estelle
> wanted to solve).
> Cheers,
> Anton Prowse
> http://dev.moonhenge.net
This issue I am having, however, is not with the :not or the :nth-of- 
type, it is with the selection order or process.

I am looking for
Of the image that have src*=photo, match the odd ones.

I am getting

Of the Odd images on the page, match the ones that also have source  

Is this a correct browser rendering according to the specificiations?  
I there a way to return first the attribute selector portion, then  
apply the nth-of-type pseudo class on top of that?

Received on Sunday, 4 July 2010 19:50:10 UTC

This archive was generated by hypermail 2.4.0 : Friday, 25 March 2022 10:07:48 UTC