IE 的 Conditional comments 可以拿來建立對應的 class,可以減少 css 使用 IE hack 的情況 (有些 IE hack 會使得 css 的語法不正確,用工具壓縮後可能會出問題),以 IE6 為例,下面的例子可以把 IE6 與 IE7 分別標上 class="ie6"
或是 class="ie7"
:
<!--[if IE 6]><body class="ie6"><![endif]--> <!--[if IE 7]><body class="ie7"><![endif]--> <!--[if gt IE 7]><!--><body><!--<![endif]-->
這個方式不需要 javascript,而且是合法的 HTML (只有 IE 會看懂 comment 內的說明)...