views:

1563

answers:

4

I'm trying to override a few css selectors that are causing problems in IE6 by using the following code inside the head tag in an html file:

<!--[if IE 6]
<style type="text/css">
    @import ("ie6.css");
</style>
<![endif]-->

This code comes after the main stylesheet loads, and no other stylesheets get loaded after the conditional comment. For some reason, browsing the site using IE6 doesn't load the IE6 css file. I've tried numerous variations on the syntax and I've also tried using a link tag instead of style import, all to no avail.

I do have some JavaScript that dynamically alters some style properties for the same elements that the selectors are for, but I don't think that is the problem because when I just replace the same selectors in the main css file, everything works as expected. So it would seem that the IE6 css file never loads.

Any thoughts or ideas will be greatly appreciated. Thanks.

+3  A: 

Actually you only left out the closing bracket for the opening conditional comment tag [if IE 6]> <----

<!--[if IE 6]>
IE6 stuff here.
<![endif]-->

Also, you may want to do the @import with either url("ie6.css"); or just the quotes.

@import url("ie6.css");
@import "ie6.css";
Mister Lucky
lol, man I've been staring at the screen for too long to miss something like that. I had tried both of the import suggestions you pose, but of course, without the closing > they...ahem...didn't seem to help. I'll put the url back in now that the real problem is solved. Thanks. +1 and answer.
Bryan
There's no particular need for the @import rule is there? If you're using conditional comments in HTML you can just put a simple <link> inside them.
bobince
no problem, it's quite often the silly typos that get to us in coding! best of luck to you..
Mister Lucky
A: 

Also if you have multiple IEs set up incorrectly, you need to delete a key in the registry to get IE6 to think it actually is IE6.

alex
I'm using Virtual PC with a disk image that has IE6 on it. It works as expected now that I've corrected the glaring oversight that Mister Lucky pointed out. I'll check out the article you link to anyway, it looks pretty interesting. Thanks.
Bryan
A: 

I'm having this same problem, with IE6 not loading a stylesheet in conditional comments. I've confirmed the CC syntax is correct, and also tried the suggestion by Alex regarding deleting a key in the registry with no luck. I've also done a complete reinstall of windows on the machine I use to test IE6 rendering. Any further suggestions? Here's the link, if you're interested:

http://themes.nimblehost.com/customerpreview/ddtheme

Many thanks!

Update I've discovered that the problem is because IE6 is only able to parse the first 30 stylesheets. Too bad I'm in the situation where I can't condense these stylesheets together...

A: 

css float problem in IE.

float diplay the boxes one below one