Paola_V Paola_V - 20 days ago 7
HTML Question

Conditional comments syntax

Can anyone explain me the difference between first and second conditional comment syntax?

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


Why the second one use use the
<!-->
syntax before
<html>
tag? Can I use the following syntax with the same result?

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


Thanks in advance!

Answer

No, your second setup will not be the same as your first.

In the first, where <!--[if gt IE 8]><!--><html class="no-js"><!--<![endif]--> is used, it will let all other browsers (the one's that does not understand conditional comments) to have <html class="no-js">, which the second setup won't

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

Comments