tags:

views:

282

answers:

4

IE7 doesn't support :last-child pseudo selector. I am thinking of explicitly adding a class name to denote it as the last element but not sure how to select this element inside a css file. Anyone have any ideas on how to do this ?

+7  A: 
.class1.class2 {color:red}

and

<div class="class1 class2"></div>

or install IE7-js and :last-child will "just work".

SpliFF
Note that IE6 is broken when it comes to multiple class selectors like this. http://www.ryanbrill.com/archives/multiple-classes-in-ie/ explains in more detail and has a work around.
David Dorward
the IE7-js library is also a work-around, and it enables first/last-child as well. I love it.
SpliFF
A: 

This page has all you want to know about multiple class names

cbp
+2  A: 

If you have

<div class="element"/>
<div class="element last"/>

You can just do

div.element
{
   // styles effect both divs
}

div.last
{
    // style will only effect the second element and overides because lower in the css
}
Nick Allen - Tungle139
A: 

One extra thing to note about multiple classnames is that IE6 can not handle them properly. It will only consider the last classname in the list:

.class1.class2 {color:red} => .class2 in IE6
PatrikAkerstrand