Les commentaires conditionnels sont pas des instructions spéciales interprétables par le navigateur Internet Explorer de Microsoft Windows.
Ils sont déjà pris en charge par la version 5.0, mais très peu sont en mesure d'exploiter son potentiel considérable, en particulier dans la correction des interprétations du droit anormales CSS à partir du navigateur de Microsoft.
Vous pouvez utiliser les commentaires conditionnels distinguant même la version d'Internet Explorer utilisée par le navigateur, la réalisation des effets (ou des corrections) diffèrent selon les caractéristiques (ou l'absence) de la version spécifique.
Les commentaires conditionnels suivre une syntaxe très simple, comme dans ce qui suit:
<!--[if IE 6]>
Qui ci metto istruzioni specifiche per Internet Explorer 6
<![endif]-->
Comme on le voit, le commentaire conditionnel est une commande entouré de marqueurs de commentaires HTML: de cette manière le navigateur ne supporte pas cette fonction d'ignorer complètement le commentaire et les instructions qui y sont contenues.
Attention! Pour cette raison, les commentaires conditionnels ne peut pas être utilisé directement dans les feuilles de style, mais doit être incluse doit être dans les pages HTML normales.
Voici un autre exemple simple mais complet:
<p><!--[if IE]>
Stai utilizzando Internet Explorer<br />
<![endif]-->
<!--[if IE 5]>
Stai utilizzando Internet Explorer 5<br />
<![endif]-->
<!--[if IE 5.0]>
Stai utilizzando Internet Explorer 5.0<br />
<![endif]-->
<!--[if IE 5.5]>
Stai utilizzando Internet Explorer 5.5<br />
<![endif]-->
<!--[if IE 6]>
Stai utilizzando Internet Explorer 6<br />
<![endif]-->
<!--[if IE 7]>
Stai utilizzando Internet Explorer 7<br />
<![endif]-->
<!--[if gte IE 5]>
Stai utilizzando Internet Explorer, versione 5 o superiore<br />
<![endif]-->
<!--[if lt IE 6]>
Stai utilizzando Internet Explorer, versione inferiore alla 6<br />
<![endif]-->
<!--[if lte IE 5.5]>
Stai utilizzando Internet Explorer, versione inferiore o uguale alla 5.5<br />
<![endif]-->
<!--[if gt IE 6]>
Stai utilizzando Internet Explorer, versione superiore alla 6<br />
<![endif]-->
</p>
<p><!--[if IE]>
Stai utilizzando Internet Explorer<br />
<![endif]-->
<!--[if IE 5]>
Stai utilizzando Internet Explorer 5<br />
<![endif]-->
<!--[if IE 5.0]>
Stai utilizzando Internet Explorer 5.0<br />
<![endif]-->
<!--[if IE 5.5]>
Stai utilizzando Internet Explorer 5.5<br />
<![endif]-->
<!--[if IE 6]>
Stai utilizzando Internet Explorer 6<br />
<![endif]-->
<!--[if IE 7]>
Stai utilizzando Internet Explorer 7<br />
<![endif]-->
<!--[if gte IE 5]>
Stai utilizzando Internet Explorer, versione 5 o superiore<br />
<![endif]-->
<!--[if lt IE 6]>
Stai utilizzando Internet Explorer, versione inferiore alla 6<br />
<![endif]-->
<!--[if lte IE 5.5]>
Stai utilizzando Internet Explorer, versione inferiore o uguale alla 5.5<br />
<![endif]-->
<!--[if gt IE 6]>
Stai utilizzando Internet Explorer, versione superiore alla 6<br />
<![endif]-->
</p> Le résultat de cette simple liste de commentaires conditionnels est montré dans les lignes suivantes, à condition que vous utilisez Internet Explorer (non recommandé):