条件注释语法

Conditional comments syntax

谁能解释一下第一个和第二个条件注释语法之间的区别?

<!--[if lt IE 8]><html class="no-js lt-ie8"><![endif]-->
<!--[if gt IE 8]><!--><html class="no-js"><!--<![endif]-->

为什么第二个在 <html> 标签之前使用 <!--> 语法?我可以使用以下语法得到相同的结果吗?

<!--[if lt IE 8]><html class="no-js lt-ie8"><![endif]-->
<!--[if gt IE 8]><html class="no-js"><![endif]-->

提前致谢!

不,您的第二次设置将与第一次不同。

第一个使用 <!--[if gt IE 8]><!--><html class="no-js"><!--<![endif]--> 的地方,它会让所有其他浏览器(那些不理解条件注释的浏览器)拥有 <html class="no-js">,而第二个设置不会

来源:https://msdn.microsoft.com/en-us/library/ms537512(v=vs.85).aspx

一般接受的语法是 (was)

open tag   : <!--[if condition version]>
end tag    : <![endif]-->

最好的猜测是它在 bogus comment. Two dashes after <! make it a comment node in the DOM. Refer this answer

尝试
<!--[if gt IE 8]><!--><html class="no-js"><!--<![endif]-->
                 ^^^^^                    ^^^^       
                 |||||                    ||||
                 ________Bogus Comment________

这并没有什么区别。最后一个可能会呈现为 <!-- comment -->comment + condition ...不确定。