How to write a style for IE only

I thought I had seen something that did this before, but I was unable to find it after a quick search. I want some selector/hack that will allow me to write a style that will only be understood by IE. I need to position an element 1 or 2 pixels to the right in IE only. My style looks fine in FF and NN. I was hoping to do something like:


.myclass { margin-left: 5px; }
/* something for IE only */ .myclass { margin-left: 7px; }


Any suggestions?i think its

* .myclass { margin-left: 7px; }

make sure there is a space between the asterisk and the selector.


however, if you find yourself collecting a number of the IE only styles, you could put em all in a separate stylesheet and add a link in the head section of your html like so:


<!--[if IE]><link rel="stylesheet" type="text/css" href=http://www.webdeveloper.com/forum/archive/index.php/"ie.css" /><![endif]-->Use the conditional comment not the universal selector which may be fix in IE7So far, I only have this one item that needs to be styled differently for IE, so I don't necessarily want to create a separate stylesheet just for this simple thing. It is definite that the universal selector will be fixed in IE7? Are there any other options?conditional comments are the only certain way to do it.Try this:
.myclass {margin-left: 5px !important; margin-left: 7px;}Try this:
.myclass {margin-left: 5px !important; margin-left: 7px;}
Yet another fix!
 
Back
Top