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

前端 未结 1 733
遇见更好的自我
遇见更好的自我 2021-01-17 00:15

How do you use conditional comments to target

  1. Internet Explorer only

  2. Certain IE versions

  3. Certain IE versions and all other b

相关标签:
1条回答
  • 2021-01-17 00:50

    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]-->
    
    0 讨论(0)
提交回复
热议问题