Valid conditional comments to target non-IE browsers and specific IE versions

做~自己de王妃 提交于 2019-12-01 12:59:34

问题


How do you use conditional comments to target

  1. Internet Explorer only

  2. Certain IE versions

  3. Certain IE versions and all other browsers

  4. No IE, just other browsers

in a way that validates? (validator.w3.org/)


回答1:


I tested these and they're valid HTML.

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


来源:https://stackoverflow.com/questions/33132856/valid-conditional-comments-to-target-non-ie-browsers-and-specific-ie-versions

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!