CSS for different versions of IE

CSS for different versions of IE

Nov 2, 2010·

2 min read

Some times your site looks different in IE 6 then it does in 7 or in Firefox. Most of the time you can combat this with better coding but there's times when that just not enough.

in them situations you can use condition statements for IE6 & IE7 in these conditions you would ran an alternate version of your CSS code an example of this:

<!--[if lte IE 6]>


<p>This would be placed in between the head tags</p>

<p>if lte IE 6 means if the browser is IE 6 then run the following code and the same applies to if lte IE 7</p>

<p>you can either put some simple style changes in the if statement like this</p>

<code class="language-css"><style type="text/css" media="all">
#box {

or import another stylesheet which is a better approach as your source code looks cleaner. Like this :


any CSS style called inside the if statements take precedence over the main stylesheet and take effect instead of what's in the main stylesheet for that element.

Hopefully this will help you get around some of the problems you have with different versions of IE.

Did you find this article valuable?

Support David Carr by becoming a sponsor. Any amount is appreciated!