Conditional Comments in Internet Explorer
The standard way of including comments in HTML is by enclosing those between <!– and –> using which browser ignores the text and HTML markups enclosed therein.
Starting with IE 5 Microsoft came up with Conditional Comments that allow you to include text/html-code and use/ignore them for specific IE versions.
Depending on whether Conditional Comments would be understood by browsers (not just IE) they are classified as :
| Uplevel Browsers | All IE versions 5 and above comes under this category. |
|---|---|
| Downlevel Browsers | IE versions below 5 are unaware of developments of future, and thus comes under this category. Further since Conditional Comments are Microsoft standards other browsers are not bound to abide by them (and surely are not doing so), they fall under this category. |
Now, to how the Conditional Comments are implemented. This is done using [if <condition>] . . . . [endif] block. How and where the block is used depends on what you want the Downlevel browsers to do with text/code that’s commented out (of course they would do it unconditionally).
Treat the comments as unconditionally commented
In this case you would be required to place code as something below
<!--[if <condition>]> Text that goes unnoticed by Downlevel browsers <a href="http://somewhere.com">and so the markups and links</a> <[endif]-->
Nothing new as the text and markup as above would have been treated as comments even if Microsoft had not come up with Conditional Comments concept.
Show up the Texts and Markups as would when not commented
In this case you would be required to place code as something below
<![if <condition>]> Text that shows up on Downlevel browsers <a href="http://somewhere.com">and so the markups and links</a> <[endif]>
If you notice the only difference above is that the hyphens — are not used, in absence of which <![if <condition>]> is treated as would any unsupported HTML tag by the Downlevel browsers and ignored and the content within parsed and shown up.
Now, let me describe what comes for the <!–[if <condition>]>
When elaborated <![if <condition>]> looks like
<!--[if <operator> <comparision> <feature> <version>]>
Currently there is only one defined feature i.e. IE. In its simplest form Conditional Comment would begin with something like
<!--[if IE]>
This would ensure that if the browser is IE the text and markups contained would be shown up. Be aware that Downlevel browsers don’t understand these rules which all browsers other than IE are! And so are IE versions below 5. So practically only IE 5 and above would show the content.
You can also specify versions as
<!--[if IE 5.5]>
Or use NOT operator “!” as
<!--[if !IE 7]>
Or use other comparisons as lt (less than), lte (less than or equal to), gt (greater than), (greater than or equal to)
<!--[if IE gte 6]>
Using as above you can modify your page code to contain version specific code to ensure that your page renders same on all IE versions.
Conditional Comments discussed above are useful indeed as in absence of which you would be required to use JavaScript to check for the User Agent and it’s version and include code using document.write(). Unfortunately no other browser seems to be inclined to include and support it just for the fact that it’s suggested by Microsoft. One such HTML extension added by Microsoft was the MARQUEE that always remained a Microsoft extension and never included in standards. Even if rendering same effect required Java applets or JavaScript codes on other browsers, they seem to be happy doing it. Others like to reinvent a better(?) wheel even if Microsoft has already invented one.



A google search picked up a ton. ,
Maxx72
22 Oct 09 at 9:08 pm