On Sep 6, 2009, at 1:12 PM, Chang Huang wrote:

> Hi, I'm trying to get the last element that belongs to a specific
> class. For example,
>
> <ul>
>       <li>aaa</li>
>       <li class="special">bbb</li>
>       <li>ccc</li>
>       <li>ddd</li>
>       <li>eee</li>
>       <li class="special">fff</li>
>       <li class="special">ggg</li>
>       <li>hhh</li>
> </ul>
>
> I need to get the last 'li' with the class 'special' ('<li
> class="special">ggg</li>'), is it possible to do that without JS?
>
> I tried '.special:last-child { color:red; }', but it doesn't seem to
> work.

I don't think that would work anywhere.
Pseudo-classes are applied to type selectors or the universal selector.
http://www.w3.org/TR/css3-selectors/#pseudo-classes
Further down, the prose refers to 'elements' (a class is not an  
element nor a type selector).

Type selectors are defined in 6.1
http://www.w3.org/TR/css3-selectors/#type-selectors
Class selectors
http://www.w3.org/TR/css3-selectors/#class-html

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