Web design & marketing tips by Ironpaper

Conditional Comments HTML - Internet Explorer Issues In Web Design

Written by Ironpaper | Sep 21, 2009 5:55:41 PM

Conditional comments work in Internet Explorer and on Windows only.  For this reason, you can create special instructions to be executed by Internet Explorer only ( on Windows ). Conditional comments are for Internet Explorer 5 and higher.

The basic structure of a conditional comment is the same as an HTML comment (<!-- -->). When another browser sees such comments, they will simply ignore them.

This code snippet will target Internet Explorer 6:

<!--[if IE 6]>
Special instructions for IE 6 here
<![endif]-->

This code snippet will target Internet Explorer:

<!--[if IE 7]>
According to the conditional comment this is Internet Explorer 7<br />
<![endif]-->

This will target the browser: Internet Explorer and all versions above 5:

<!--[if IE]>
According to the conditional comment this is Internet Explorer<br />
<![endif]-->