1

I have come across:

/* for firefox only */
@-moz-document url-prefix() {
#main_menu ul ul {
top: 37px;
}
}

which can be used to define firefox styling only, is there a similar alternative to use for defining styles to be used with IE only? or is the 'conditional stylesheet' approach here considered best practise?

http://css-tricks.com/how-to-create-an-ie-only-stylesheet/

in this instance I am only wanting to change the top margin of a drop down css menu and so only a few styles need to be tweaked for ie.

thank you.

ps i have come across:

Setting CSS for IE only?

and am trying to put:

<!--[if IE]><!--> <html class="ie"> <!--<![endif]-->

in the head and then define in the css with:

.ie#main_menu ul ul {
top: 50px !important;
}

but I cannot see any change in IE.

3 Answers 3

2

You should put this code in HTML file, after your general CSS. Now, you will have another CSS file (ie.css) which will be applied for browsers Greater Then (and Equal) IE6 and Later Then IE8 (and Equal).

<!--[if (gte IE 6)&(lte IE 8)]>
  <link rel="stylesheet" href="css/ie8.css" media="screen,all" />
<![endif]-->

Or you can use "star property hack" in your original CSS file. Put a star in front of your CSS rule and you will target IE7 and lower versions. Example:

div{
  top:20px;
  *top:10px;
}
1
  • FYI, IE 10 no longer supports conditional comments Apr 10, 2013 at 23:38
0

Are you testing with REAL versions of IE or are you changing the version in Developer Tools? Developer Tools in IE almost NEVER show an accurate representation of what it should look like in IE 8, for example.

0

Have you checked if your style rule is applied without the condition first? Probably there is a problem in your CSS selector. I believe your CSS selector should be ".ie #main_menu ul ul" instead of what you have. Notice the space after ".ie"

.ie #main_menu ul ul {
    top: 50px !important;
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.