954,591 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

css ie6 ie7 if statements?

Hi, I am having issues attaching the following if statements in the head of my page to show the correct CSS for older versions of IE. I am using :

_mike_
Newbie Poster
17 posts since May 2010
Reputation Points: 10
Solved Threads: 0
 

Try removing the leading slash, as these are used to define absolute paths

<!--[if lte IE 6]>
    <link rel="stylesheet" type="text/css" href="css/mainiesix.css" />
<![endif]-->

<!--[if IE 7]>
<link rel="stylesheet" type="text/css" href="css/mainieseven.css"  />
<![endif]-->
macneato
Posting Pro in Training
421 posts since Jun 2007
Reputation Points: 46
Solved Threads: 48
 

Hi thanks for fast response, I actually put that slash in to try, but its not working either way. It's wierd because if i replace the main .css with one of the IE stylesheets they work fine, so it must be something in the above code. I'm placing it in the of the page which i believe is correct?

_mike_
Newbie Poster
17 posts since May 2010
Reputation Points: 10
Solved Threads: 0
 

Yes, that is correct. Very stange to say the least. Are you working on the site locally, if not, could you post a link?

macneato
Posting Pro in Training
421 posts since Jun 2007
Reputation Points: 46
Solved Threads: 48
 

I have pm'd ou the link. thanks for having a look

_mike_
Newbie Poster
17 posts since May 2010
Reputation Points: 10
Solved Threads: 0
 

This should do the trick. Switch the order.

<link href="css/main.css" rel="stylesheet" type="text/css" />
<!--[if lte IE 6]>
<link rel="stylesheet" type="text/css" href="/css/mainiesix.css" />
<![endif]-->

<!--[if IE 7]>
<link href="/css/mainieseven.css" rel="stylesheet" type="text/css" />
<![endif]-->
macneato
Posting Pro in Training
421 posts since Jun 2007
Reputation Points: 46
Solved Threads: 48
 

hhmmm just uploaded that new order, still not working in IE6 or 7 ... very odd.. I thought at first I had named the .css files incorrectly, but they work indepenently if i put them as the main css.... its really strange! I have a seperate pc to test IE6 and also using software called IETester to test ie7, but theyrte not picking up the style sheets at all.....

_mike_
Newbie Poster
17 posts since May 2010
Reputation Points: 10
Solved Threads: 0
 

I've tested both on IEtester. It should work. To do a simple test try

<title>...meeting rooms -</title>
<meta http-equiv="content-type" content="text/html;charset=UTF-8" />
<link href="css/main.css" rel="stylesheet" type="text/css" />
<!--[if lte IE 6]>
    <link rel="stylesheet" type="text/css" href="css/mainiesix.css" />
    <style>
    body {
    background:#000;
    font-size:40px
    }
    </style>
<![endif]-->
<!--[if IE 7]>
    <link rel="stylesheet" type="text/css" href="css/mainieseven.css"  />
    <style>
    body {
    background:red;
    font-size:40px
    }
    </style>
<![endif]-->


Test in ie6, bg will be black, in ie7 bg will be red and in ff, it will display as default

macneato
Posting Pro in Training
421 posts since Jun 2007
Reputation Points: 46
Solved Threads: 48
 

Thats very interesting, thanks, yeah that does change the backgroung correctly, but the actual css in the attached stylesheet doesnt kick in. Maybe i should just put the entire css where you have placed the background color css. Seems strange though. I'll have a look and see if that works!

_mike_
Newbie Poster
17 posts since May 2010
Reputation Points: 10
Solved Threads: 0
 

I have tried the above, its works but then what about any browser outside of IE. If i add the default style sheet it over rules everything else... Nightmare, still can't see why just the follwoing code won't settle this

_mike_
Newbie Poster
17 posts since May 2010
Reputation Points: 10
Solved Threads: 0
 

I have now replaced with this


and taken out the main css :


This now works in IE8 , 7 and 6, but obviously not in any other browser as i have taken that last main.css link out... So now i need to tell the browser to load the main.css if its not Internet explorer? any ideas?

_mike_
Newbie Poster
17 posts since May 2010
Reputation Points: 10
Solved Threads: 0
 

Finally it now works... I used the following:

_mike_
Newbie Poster
17 posts since May 2010
Reputation Points: 10
Solved Threads: 0
 
macneato
Posting Pro in Training
421 posts since Jun 2007
Reputation Points: 46
Solved Threads: 48
 

So you are saying is if you put your main stylesheet above that code and you open your site in firefox that it is all messed up? How? Do you have a link we can view this?

jrock2004
Light Poster
35 posts since Jul 2010
Reputation Points: 10
Solved Threads: 2
 

Its ok, this

is the answer!

Thanks macneato for helping me with this... First post on here so will be back :)

Cheers jrock2004

_mike_
Newbie Poster
17 posts since May 2010
Reputation Points: 10
Solved Threads: 0
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You
View similar articles that have also been tagged: