IE 有條件注釋是 Microsoft 對 HTML 註解的擴充寫法,可讓開發者依據 Internet Explorer 版本,決定是否載入特定程式碼。它並非標準語法,但因為對其他瀏覽器而言只是註解,所以通常不會造成影響。
只有 IE 會解析的區塊:
<!--[if IE]> <p>這段內容只會在 IE 中顯示。</p> <![endif]-->
指定特定版本:
<!--[if IE 8]> <style type="text/css"> @import "test.css"; </style> <![endif]-->

排除特定版本:
<!--[if !IE 7]> <style type="text/css"> @import "test.css"; </style> <![endif]-->

有條件注釋適合短期相容或針對少數版本修正。若專案需要長期維護,建議優先使用標準 CSS、Progressive Enhancement 或 Feature Detection,並將相容樣式集中管理。