开发者

CSS: How to load a css file for all browsers except IE?

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]>
  <开发者_StackOverflow社区;![endif]-->

thanks


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

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

<![if !IE]>
...
<![endif]>


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]-->


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. :)


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

more info here

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜