11 Sep

IE Only Conditional Comments

That little gem that is IE only style sheets, …in the head, BELOW the normal style sheet you put

<!--[if IE]>
<link rel="stylesheet" media="all" type="text/css" href="iestyle.css" />
<![endif]-->

you can add a version number after the IE to target specific versions, …just remember to only put in the properties that ACTUALLY need changing, not all of them.

This IE only comment can actually be used for many other things, it basically just allows IE to render whatever is in the comments.

Enjoi.

Full Example of all version usage below.

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

According to the conditional comment this is Internet Explorer 5<<![endif]-->

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

<![endif]-->

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

<![endif]-->

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

<![endif]-->

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

<![endif]-->

<!--[if gte IE 5]>
According to the conditional comment this is Internet Explorer 5 and up

<![endif]-->

<!--[if lt IE 6]>
According to the conditional comment this is Internet Explorer lower than 6

<![endif]-->

<!--[if lte IE 5.5]>
According to the conditional comment this is Internet Explorer lower or equal to 5.5

<![endif]-->

<!--[if gt IE 6]>
According to the conditional comment this is Internet Explorer greater than 6

<![endif]-->

If you enjoyed this post, make sure you subscribe to my RSS feed!