How to select an html element with two class names?

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

+6
html css frontend
source share
3 answers
.class1.class2 {color:red} 

and

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

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

+14
source share

If you

 <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 } 
+3
source share

Another thing worth noting about several classes is that IE6 cannot handle them correctly. It will consider only the last class name in the list:

 .class1.class2 {color:red} => .class2 in IE6 
0
source share

All Articles