HyperText Markup Language/Conditional Comments

Conditional comments are a proprietary extension to Microsoft Internet Explorer for Windows (IE/win) version 4.0 and later. They are not available in Internet Explorer for Mac (IE/mac). They are a very useful way of handling the CSS bugs in the various versions of Internet Explorer.

Syntax
An ordinary (X)HTML comment looks like this:

Conditional comments add additional syntax to comments. The simplest example is:

Browsers that don't understand the conditional comment syntax will process this as a normal comment, i.e. the content of the comment will be ignored.

Specific versions of IE/win can be targeted by changing the expression after the. For example to target any version of IE/win with a major version of 5 use: The text will display in IE/win versions 5.0 and 5.5.

To target a specific version number, e.g. 5.0, the syntax is slightly quirky.

Inequalities can be used in the expression by placing an operator before the. The operators are:
 * : less than (but at least version 5.0 which is the lowest version supporting conditional comments)
 * : less than or equal (but at least version 5.0 which is the lowest version supporting conditional comments)
 * : greater than
 * : greater than or equals

Example:

All the expressions can be negated by prefixing with, e.g.

The second example may seem pointless but with a small tweak you can arrange to hide text from IE/win version 5 and above.

The following HTML document is a working example.

Use with CSS
Conditional comments can be used to pass additional stylesheets to IE/win. These stylesheets can provide fixes to layout bugs in IE/win. The basic idea is: