“Conditional Comments” (CC) are most commonly used to differentiating Cascading Style Sheets (CSS) rules intended for specific versions of Internet Explorer. Conditional comments are proprietary conditional statements interpreted by Microsoft Internet Explorer. Conditional comments have been available since MSIE 5 Windows and later (Mac IE doesn’t support them.). The most beneficial aspect of conditional comments is that you are not trusting on browser bugs when using them.
How to write a conditional comment
The following conditional comment is being picked up by IE5, IE5.5 and IE6:
simply we define as:
If you need to target IE5 specifically, you do so by appending a version number:
<!–[if IE 5.0]>
<link rel=”stylesheet” type=”text/css” href=”style5.0.css” />
<![endif]–>
Targeting IE5.5
If you specifically need to target IE5.5, it’d look like this:
<!–[if IE 5.5]>
<link rel=”stylesheet” type=”text/css” href=”style5.5.css” />
<![endif]–>
Targeting IE6
The same goes for IE6:
<!–[if IE 6]>
<link rel=”stylesheet” type=”text/css” href=”style6.0.css” />
<![endif]–>
and we can right it in details as:
According to the conditional comment this is Internet Explorer<br />
<![endif]–>
<!–[if IE 5]>
According to the conditional comment this is Internet Explorer 5<br />
<![endif]–>
<!–[if IE 5.0]>
According to the conditional comment this is Internet Explorer 5.0<br />
<![endif]–>
<!–[if IE 5.5]>
According to the conditional comment this is Internet Explorer 5.5<br />
<![endif]–>
<!–[if IE 6]>
According to the conditional comment this is Internet Explorer 6<br />
<![endif]–>
<!–[if IE 7]>
According to the conditional comment this is Internet Explorer 7<br />
<![endif]–>
<!–[if gte IE 5]>
According to the conditional comment this is Internet Explorer 5 and up<br />
<![endif]–>
<!–[if lt IE 6]>
According to the conditional comment this is Internet Explorer lower than 6<br />
<![endif]–>
<!–[if lte IE 5.5]>
According to the conditional comment this is Internet Explorer lower or equal to 5.5<br />
<![endif]–>
<!–[if gt IE 6]>
According to the conditional comment this is Internet Explorer greater than 6<br />
<![endif]–>
We can any of these parameters in our conditional comment:
- IE- Any version of IE
- lte – less than or equal
- lt – less than
- gte – greater than or equal
- gt – great than
- (IE6)|(IE7) – if Internet Explorer 6 OR Internet Explorer 7
- (IE6)&(IE7) – if Internet Explorer 6 AND Internet Explorer 7
cheers!!
Joginder Poswal
Thanks buddy. nice to see all this info
Thanks subhash.