tags:

views:

76

answers:

4

hi,

how can I load a css file only if the browser is not IE ?

In other terms, I want to load a css file only if it is Safari, Firefox o Chrome. The opposite of this:

<!--[if IE 8]>
  <![endif]-->

thanks

A: 
<!--[if !IE]>
<![endif]-->

more info here

Elf King
this won't work, you need to use "downlevel-revealed" conditional comments. See http://msdn.microsoft.com/en-us/library/ms537512(VS.85).aspx#dlrevealed
Graham Clark
it will work for the question posted. "how can I load a css file only if the browser is not IE" I refer you to the table in the same location you posted, the very first entry in the truth table on that page.
Elf King
+2  A: 

I believe based off this article http://msdn.microsoft.com/en-us/library/ms537512%28VS.85%29.aspx you can do this:

<![if !IE]>
   Other browser code here
<![endif]>

Edited the above to be valid. The link at microsoft shows the above, but RoToRa is correct that it is invalid and should be (note, contrary to RoToRa, you don't need the extra "!" before the "endif" inside the brackets):

<!--[if !IE]>-->
  Other browser code here
<!--[endif]-->
Scott
These are called Downlevel-Revealed conditional comments, as opposed to the more common Downlevel-Hidden ones.
Graham Clark
+7  A: 
<!--[if !IE]>-->
...
<!--<![endif]-->

Don't use the following. It is invalid HTML:

<![if !IE]>
...
<![endif]>
RoToRa
Not clear which form is the subject of "this" :)
annakata
@annakata we can only assume the bottom one, as we know the top to be comment syntax `<!--` *...* `-->`
Evan Carroll
Updated to make clearer.
RoToRa
A: 

In addition to the plethora of correct answers above, it's worth asking yourself why you're doing this - it's usually more correct to include a file only for IE since it is only IE which meaningfully deviates from the standards.

The inverse form also has the benefit of being considerably more readable, imho. :)

annakata