Conditional comments for IE

Conditional comments are used to write special instructions that only work in Internet Explorer below version 5.
Conditional comment looks like this:
<!-[if IE]> Here place special instructions for IE. <![endif]-->
The structure is similar to a usual comment in HTML, therefor all other browsers will see it as a normal comment. Explorer recognizes the special syntax <!--[if IE]>, resolves the if and parses the content of the conditional comment as if it were a normal page content. Conditional comments use the syntax of HTML comments, so they can only be included in the HTML page. It is convenient to put special styles for IE and paste the "link" tag in the conditional comments.
Below are given several conditional comments that show the version of Internet Explorer, you are using.
<!--[if IE]> Instructions for Internet Explorer <![endif]--> <!--[if IE 5]> Instructions for IE 5 <![endif]--> <!--[if IE 5.0]> Instructions for IE 5.0 <![endif]--> <!--[if IE 5.5]> Instructions for IE 5.5 <![endif]--> <!--[if IE 6]> instructions for IE 6 <![endif]--> <!--[if IE 7]> Instructions for IE 7 <![endif]-->
In the conditional comments, you can use conditional statements in which you can specify a more complex condition. The table below lists all the operators.
Conditional statements | Description |
---|---|
lt | less than |
lte | less than or equal |
gt | greater than |
gte | greater than or equal |
And some examples:
<!--[if ! IE 5]> Instructions for IE 5.5, 6, or 7 <![endif]--> <!--[if gt IE 5.0]> Instructions for IE 5.5, 6, or 7 <![endif]--> <!--[if lte IE 5.5]> Instructions for IE 5.0 or 5.5 <![endif]--> <!--[if gte IE 6]> instructions for IE 6 or 7 <![endif]--> <!--[if lt IE 7]> Instructions for IE 5.0, 5.5, or 6 <![endif]-->