Tuesday, September 22, 2009

Conditional Comments in Internet Explorer

Conditional comments allow you to have one block of code for some versions of IE and a different block of code for everything else. I've found that IE 5.2 for mac, for instance, does not support conditional comments, but IE 5 through IE 7 on windows seem to support conditional comments.

This code loaded in a browser will tell you whether or not it supports conditional comments:

<!--[if IE]><p>You are using an Internet Explorer that supports conditional comments.</p><![endif]-->
<![if !IE]><p>You are not using an Internet Explorer that supports conditional comments.</p><![endif]>

I recommend using it on live sites sparingly.

No comments: