04May2011
Author
Dave
Category
CSS
Tags
, ,
CSS for different versions of IE Thumbnail

CSS for different versions of IE

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.

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]>
<style type="text/css" media="all">
#box {
  padding-top:50px;
  text-align:center;
  color:#FFFFFF;
  font-weight:bold;
}
</style>
<![endif]-->
 
<!--[if lte IE 7]>
<style type="text/css" media="all">
#box {
  padding-top:50px;
  text-align:center;
  color:#FFFFFF;
  font-weight:bold;
</style>
<![endif]-->

This would be placed in between the head tags

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

you can either put some simple style changes in the if statement like this

<style type="text/css" media="all">
#box {
  padding-top:50px;
  text-align:center;
  color:#FFFFFF;
  font-weight:bold;
</style>

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

<style type="text/css">
<!--
@import url("style/ie6.css");
-->
</style>

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.

Author
Dave

About the Author

has written 72 articles on Dave is my name.

My name is David Carr I'm a PHP web developer based in Hull it is my passion to design and develop clean, accessible and usable websites using PHP and other web technologies, I'm an avid Twitter user why not follow me? https://twitter.com/daveismynamecom

Visit this author's website   ·   View more posts by

Sharing is caring.
  • Subscribe to our feed
  • Share this post on Delicious
  • StumbleUpon this post
  • Share this post on Digg
  • Tweet about this post
  • Share this post on Mixx
  • Share this post on Technorati
  • Share this post on Facebook
  • Share this post on NewsVine
  • Share this post on Reddit
  • Share this post on Google
  • Share this post on LinkedIn

Discussion

No responses to "CSS for different versions of IE"

There are no comments yet, add one below.

Leave a Comment