0

i want to add that for all version of IE (Version 6 to last one) only but nothing changes, i did something bad ?

UPDATED:

<!--[if IE]> <style type="text/css">.iemargin {margin-top:30px;}<![endif]-->
<!--[if !IE]><style type="text/css">.iemargin {margin-top:30px;}<![endif]-->
faty fatoumata
  • 205
  • 5
  • 20
  • please you can see this page: [Page one][1] [Page 2][2] [1]: http://stackoverflow.com/questions/14611264/x-ua-compatible-content-ie-9-ie-8-ie-7-ie-edge [2]: http://stackoverflow.com/questions/4275356/ie-compatibility-mode-x-ua-compatible-tag-edge – Ivin Raj Sep 25 '15 at 10:45

1 Answers1

1

Conditional comments are supported only in IE9 and below and not supported in IE10, IE11 or Edge. If you really need to detect browser you should use some javascript library like this (add this code in the end of file before closing </body> tag):

<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/2.1.4/jquery.min.js">
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery-browser/0.0.8/jquery.browser.min.js">
<script>$('html').addClass($.browser.name);</script>
<style>.msie .iemargin {margin-top:30px;}</style>
  1. Including jQuery. If you have it already you can skip.
  2. The library that detects browser.
  3. Adding class with browser name to html element on page.
  4. Using class .msie to apply styles only to Internet Explorer.

Fiddle: http://jsfiddle.net/av5tw588/1/

antejan
  • 2,594
  • 12
  • 15
  • so if i want a css for my div for all version of ie i can't right it directly on my html page, i need to create a css file ? – faty fatoumata Sep 25 '15 at 10:46
  • No, you can put it into your page but version 10+ of IE will ignore your conditional comment and not apply the style. – Paul Redmond Sep 25 '15 at 10:50
  • ah that's bad, so there's any solution to have a style css for all version ? – faty fatoumata Sep 25 '15 at 10:56
  • Added example of javascript based solution. Browser detection was a common thing years ago, so there was conditional comments and other things. Now all browsers works almost the same way so usually you don't need to detect browser. – antejan Sep 25 '15 at 11:27