Conditional comments using to recognise version of your IE browser
Conditional comments only work in Explorer on Windows, and are thus excellently suited to give special instructions meant only for Explorer on Windows. They are supported from Explorer 5 onwards, and it is even possible to distinguish between 5.0, 5.5 and 6.0, ie7, ie8
The syntax I use is:
<!–[if IE]>
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]–>
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]–>
Note the special syntax:
gt: greater thanlte: less than or equal to
In HTML code<!--[if IE 7]>
<style>
.ie7Div1{ width:700px; }
.ie7Div2{ width:450px;}
</style>
<![endif]-->
<!--[if IE 8]>
<style >
.ie8Div1{ width:600px; }
.ie8Div2{ width:600px;}
</style>
<![endif]-->
If your browser you're using is IE7 it will choose ie7Div1 style
and it has no style in ie8Div1
Advertisement
Categories: PHP