- From: Anton Prowse <prowse@moonhenge.net>
- Date: Sun, 04 Jul 2010 18:32:38 +0200
- To: www-style@w3.org
- CC: "L. David Baron" <dbaron@dbaron.org>, Estelle Weyl <estelle@weyl.org>
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
Received on Sunday, 4 July 2010 16:34:38 UTC