On Mar 30, 2009, at 1:27 AM, Charles wrote:

> How can I select an element combining nth-of-type() and a class/ID?
> I tried for instance li.new:nth-of-type(2) but it doesn't work. You
> can't combine both pseudo classes...
> See: http://www.adsweep.org/nth-of-type-class-id.html
> Any idea?

You can certainly combine them.

Your selector  translated:
'Selects any li element with a class attribute that contains the word  
new AND that is a second child of its type.'
<http://gallery.theopalgroup.com/selectoracle/>

The 2 conditions must be met: the element must have a class (.new) and  
it must be the second child of the ul in this case.  That would select  
the following:
<ul>
<li>foo</li>
<li class="new">bar </li> <!-- this one -->
<li>baz</li>
<li class="new">.....</li><!-- NOT this one -->
</ul>

In your demo, those conditions are not met: the second child doesn't  
have a class (.new) appended. The element you want to select is not  
the second child. The nth-of-type (as with all those structural pseudo- 
classes) applies to element E (li, or ul, or p, or a, or tr, or h1,  
etc).

BTW - you do know that browser support for those pseudo-classes is  
limited, do you ?

Philippe
---
Philippe Wittenbergh
http://l-c-n.com/





______________________________________________________________________
css-discuss [[email protected]]
http://www.css-discuss.org/mailman/listinfo/css-d
List wiki/FAQ -- http://css-discuss.incutio.com/
List policies -- http://css-discuss.org/policies.html
Supported by evolt.org -- http://www.evolt.org/help_support_evolt/

Reply via email to