19Oct/080

IE conditional statements

We all know those ugly hacks for CSS Stylesheets, and the many reasons not to use them.

IE (Internet Explorer) conditional statements allow us to create a separate stylesheet specifically for Internet Explorer browsers, we can even specify the browser version.

This is very powerful because it means you can have more control and still have a fully compliant XHTML document.

The below example will detect if the browser is Internet Explorer version 7, and if so then it will load a separate style sheet.
<!--[if lt IE 7]>
<link rel="stylesheet" type="text/css" href="style_ie7.css" />
<![endif]-->

Also, as mentioned earlier it's possible to specify a separate style sheet for Internet Explorer 6. You just need to modify the first line of the code to "IE 6", which is illustrated in the below example.
<!--[if lt IE 6]>
<link rel="stylesheet" type="text/css" href="style_ie6.css" />
<![endif]-->

Make sure to place this code just before the closing </head> tag of your website.

Comments (0) Trackbacks (0)

No comments yet.


Leave a comment


No trackbacks yet.