针对非IE浏览器和特定IE版本的有效条件注释

时间:2015-10-14 18:24:05

标签: html css internet-explorer conditional-comments

如何使用条件评论来定位

  1. 仅限Internet Explorer

  2. 某些IE版本

  3. 某些IE版本和所有其他浏览器

  4. 没有IE,只有其他浏览器

  5. 以某种方式验证? (validator.w3.org/

1 个答案:

答案 0 :(得分:1)

我测试了这些,它们是有效的HTML。

重要提示:Only IE 5 through 9 support conditional comments.

<!-- 1. IE 5-9 only: -->

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


<!-- 2. Some IE versions -->

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


<!-- 3. Some IE versions, plus all non-IE browsers -->

<!--[if gte IE 8]>-->
    <link rel="stylesheet" type="text/css" href="ie-gte8-and-non-ie.css">
<!--<![endif]-->


<!-- 4. All browsers except IE 5-9 -->

<!--[if !IE]>-->
    <link rel="stylesheet" type="text/css" href="modern-ie-and-non-ie.css">
<!--<![endif]-->
相关问题