Reputation: 22343
I am using conditional comments to link to a css file (let's call it "IEonly.css") if the IE version is less than 8. I am trying to override some properties in the regular css file. Strangely enough, IEonly.css will set new css properties correctly, but it won't override the properties in the regular CSS file!
(I am trying to make this work for IE7).
Help!
EDIT: I added an !important after the css style to see if it would help. It didn't.
Upvotes: 1
Views: 5077
Reputation: 10496
Based on my own experience of similar problems I would guess that there are some bad or missing character lurking somewhere in your IEonly.css file. They can be a real pain to track down, so do the following:
You can also try reading http://www.w3.org/TR/CSS2/cascade.html#important-rules for more information.
Can you publish some code for us to look at? That would help.
Upvotes: 0
Reputation: 268
If you are using the same selectors in both stylesheets then you should be fine as long as you place the conditional IE stylesheet after the regular stylesheet. If you do that and your IE sheet isn't taking then you might need to write more specific selectors.
#sidebar #nav li a { }
instead of...
#nav li a { }
or
li a { }
Upvotes: 3
Reputation: 22343
I added a class to the element and referenced it on the IEonly stylesheet with the class selector and the regular style sheet without. This caused the IEonly style declaration to override the regular one.
Upvotes: -1
Reputation: 813
Perhaps you can reorganize the stylesheets to default to IE styles and use an if !IE
conditional for "good browser" overrides.
Upvotes: 1
Reputation: 813
Don't forget that you can also use the !important
rule to override CSS definitions. Here is the W3C documentation on that rule.
Upvotes: 1
Reputation: 943569
Given multiple stylesheets (even if some are hidden from other browsers with conditional comments) then the normal rules of the cascade will apply.
Make sure your selectors are suitably specific, and that you apply the stylesheets in the right order.
Upvotes: 6