0

How to write the sintax on the css property like:

.example{
    /*all the browsers except IE*/
    font-size:100%;
    /*that's on all the IE syntax I need to add like a condition*/
    font-size:200%
}

That's a simple code I know, that's only to test it, but not on the html, on each property in a class, id or tag on the css.

In ie6 it's:

#test{ _color: blue}

in ie6 and ie7:

#test{ *color: blue}

ie6, ie7 and ie8:

#test{ *color: blue\9}

But how to difference between all IE and the other browsers?

Anyone can help?

jvillegas
  • 61
  • 1
  • 1
  • 10

1 Answers1

1

Use conditional stylesheets

Target IE 6 ONLY

<!--[if IE 6]>
    <link rel="stylesheet" type="text/css" href="ie6.css" />
<![endif]-->

Target IE 7 ONLY

<!--[if IE 7]>
    <link rel="stylesheet" type="text/css" href="ie7.css">
<![endif]-->

Target ALL VERSIONS of IE less than IE10

<!--[if IE]>
    <link rel="stylesheet" type="text/css" href="all-ie-only.css" />
<![endif]-->

Target everything EXCEPT IE

<!--[if !IE]><!-->
    <link rel="stylesheet" type="text/css" href="not-ie.css" />
 <!--<![endif]-->

Since IE10 ignores conditional comments you can try this solution.

Learn more about it here.

Community
  • 1
  • 1
Chankey Pathak
  • 19,330
  • 10
  • 72
  • 119
  • Doesn't IE10+ ignore conditional comments? – Paulie_D Apr 30 '14 at 10:06
  • So, @Chankey Pathak, I test it but my coworker and I talk about it, and we thougt it would be better to change it on the same css – jvillegas Apr 30 '14 at 10:06
  • @Paulie_D: What's the issue then? If the user is using IE10 then he don't need the checks for IE6,IE7 etc. – Chankey Pathak Apr 30 '14 at 10:10
  • But he said he want to target **ALL** versions of IE and your No.3 won't do that...it's target IE9 and below which is not the same thing. – Paulie_D Apr 30 '14 at 10:11
  • Because I like to use the conditional stylesheets with different css, thougt it would be better than css hacks, but my coworker likes to add css hacks than the conditional stylesheets on different css files :/ – jvillegas Apr 30 '14 at 10:13
  • @jvillegas: There are 3 possible ways. Read this: http://webdesignerwall.com/tutorials/css-specific-for-internet-explorer – Chankey Pathak Apr 30 '14 at 10:35