IE 專有的條件註釋(Conditional Comments)允許在 HTML 中針對特定 IE 版本輸出代碼,非 IE 瀏覽器視為普通註釋忽略。語法:
<!--[if IE]> 所有 IE 識別 <![endif]--> <!--[if !IE]><!--> 非 IE 識別 <!--<![endif]-->
| 運算符 | 含義 | 示例 |
|---|---|---|
| (無) | 等於指定版本 | [if IE 7] |
| gt | 大於 | [if gt IE 6] → IE7+ |
| gte | 大於等於 | [if gte IE 7] → IE7+ |
| lt | 小於 | [if lt IE 9] → IE8- |
| lte | 小於等於 | [if lte IE 8] → IE8- |
| ! | 非 | [if !IE] → 非 IE |
<!--[if IE 5.0]> 僅 IE5.0 <![endif]--> <!--[if IE 5]> IE5.0 和 IE5.5 <![endif]--> <!--[if gt IE 5.0]> IE5.0 以上 <![endif]--> <!--[if lt IE 6]> IE6 以下 <![endif]--> <!--[if IE 6]> 僅 IE6 <![endif]--> <!--[if gt IE 6]> IE6 以上 <![endif]--> <!--[if lt IE 7]> IE7 以下 <![endif]--> <!--[if IE 7]> 僅 IE7 <![endif]--> <!--[if gt IE 7]> IE7 以上 <![endif]--> <!--[if lt IE 8]> IE8 以下 <![endif]--> <!--[if IE 8]> 僅 IE8 <![endif]--> <!--[if gt IE 8]> IE8 以上 <![endif]--> <!--[if lt IE 9]> IE9 以下 <![endif]--> <!--[if IE 9]> 僅 IE9 <![endif]-->
<!--[if lt IE 9]><link rel="stylesheet" href="ie8-fix.css"><![endif]--><!--[if lt IE 9]><script src="html5shiv.js"></script><![endif]--><!--[if !IE]><!--><link rel="stylesheet" href="modern.css"><!--<![endif]-->IE10+ 已移除條件註釋支持,若需針對 IE10/11 做特殊處理,請改用特性檢測或 @media -ms-high-contrast 等 CSS Hack。現代項目建議以漸進增強策略替代版本判斷。