views:

424

answers:

5

Hi,

I'm using the IE recognized conditional statement to use an IE specific stylesheet for IE browsers:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"&gt;

<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Touringhouse</title>

<link type="text/css" rel="stylesheet" href="css/mainstyle.css" media="screen">

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

When I test my files locally this causes IE to use the specified stylesheet while other browsers use the standard stylesheet and everything appears as it should.

However, when I upload the files for viewing online, everything works in Firefox and other standards compliant browsers that use the standard (mainstyle.css) stylesheet but IE also uses the same stylesheet (mainstyle.css) - it no longer seems to see the iemainstyle.css stylesheet. I've double checked all the code and the online folder structure - it's identical to what I have locally - the iemainstyle.css file lives in the css folder alongside the mainstyle.css stylesheet. I'm not sure what's causing IE (6 and 7) to ignore the IE specific stylesheet. Thanks in advance for any help sorting this out.

A: 

Check the casing (lower vs. upper) windows ignores the casing but linux doesn't and the webserver doesn't find your file. You may also try to use absolute uris not relative.

Jikhan
Thanks for the suggestions, but I checked the case and it's fine - also tried an absolute url but still no luck. I'm wondering if it's something to do with the way my service provider's server is setup? I've tried it locally on several different machines and it works great but as I soon as I upload the files IE doesn't see the IE stylesheet anymore.
+1  A: 

I suggest you use a tool like Fiddler (http://www.fiddler2.com/fiddler2/) to inspect the http traffic between your browser and the server. You will be able to see whether the iemainstyle.css is being requested, and what is being returned by the server in response to the request.

Alohci
A: 

If you access to Safari, there is a nice tool in the "Window" menu that will show you each file loading. It will also say whether the file has been found or not. It's called "Activity", so check that one out :)

Another suggestion is try renaming the file. Sometimes using a fresh file can sort this out. Odd I know, but worth a go.

Finally, have you tried to aim your conditional statement at a specific version of IE?

i.e. (no pun intended)... This example will catch all versions less-than IE8.

<!--[if lt IE 8]>
    <link rel="stylesheet" type="text/css" href="css/iemainstyle.css" />
<![endif]-->

More info is found here: http://css-tricks.com/how-to-create-an-ie-only-stylesheet/

One more thing I noticed, try dropping the media="screen" bit, and adding in the finally forward slash to the end.

If I think of anything else, I will be back!

Im sure it will be something really obvious when you find it! Good luck, these little niggles are annoying as hell!

Edit: Just had another idea, try hosting the file somewhere else to see if that makes a difference...

Tisch
A: 

Thanks Tisch for your suggestions. The activity window in Safari is great but how is it possible to use it to see what's happening when IE loads the pages? I also tried renaming the css file and calling it from the html but no luck there. I haven't tried hosting it elsewhere yet though.

Alohci, I downloaded and ran Fiddler - nice program. It shows that IE sees the iemainstyle.css file but the icon next to it is a key icon, indicating that the response was a request for client credentials while the response to mainstyle.css is a correct CSS response. I'm not sure what the request for client credentials indicates or how to correct that?

Thanks to everyone who responded.

This is more an update to your own question than an answer. Hit the EDIT link on your question and include this bit. Then just delete this comment-as-answer.
random
+1  A: 

OK - finally got it working thanks to a friend's troubleshooting. The permissions on the IE stylesheet were set differently than on the main stylesheet. As a result, every time the conditional statement for IE was executed (telling it look for iemainstyle.css) the server would forbid access to the IE stylesheet as the permissions did not allow public access. I had to use my FTP client to change the permissions on the IE stylesheet and then everything worked.

As to why the file uploaded with different permissions when I had not touched the permissions - this may have been because the site was developed on my Mac but the IE specific stylesheet was created on my Windows machine. I copied the file over to my Mac and then used the Mac FTP client (Cyberduck) to upload to the server. That's the only reason I can think of.

Anyways, thank you to all who responded to my question.