Vamsee
Vamsee

Reputation: 862

How to select an html element that has two class names?

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 ?

Upvotes: 6

Views: 8229

Answers (3)

PatrikAkerstrand
PatrikAkerstrand

Reputation: 45731

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

Upvotes: 0

Nick Allen
Nick Allen

Reputation: 12230

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
}

Upvotes: 3

SpliFF
SpliFF

Reputation: 39014

.class1.class2 {color:red}

and

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

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

Upvotes: 14

Related Questions