Click to See Complete Forum and Search --> : How to write a style for IE only
wood_tah
01-27-2006, 08:51 AM
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?
tricia
01-27-2006, 08:57 AM
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="ie.css" /><![endif]-->
Use the conditional comment not the universal selector which may be fix in IE7
wood_tah
01-28-2006, 07:44 PM
So 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.
pcthug
01-29-2006, 03:03 AM
Try this:
.myclass {margin-left: 5px !important; margin-left: 7px;}
Try this:
.myclass {margin-left: 5px !important; margin-left: 7px;}
Yet another fix!