Web Hosting Talk







View Full Version : Overwriting CSS file with IE CSS file


Julian Jorgensen
03-11-2009, 01:50 PM
Greetings!
Just wandering if you'd know how to "overwrite" a css file. Intuitively I figured this would work:
<code>
<link rel="stylesheet" type="text/css" href="includes/stylesheet.css">
<!--[if IE 7]>
<link rel="stylesheet" type="text/css" href="includes/stylesheet-ie.css">
<![endif]-->
</code>
Where all the same style names (e.g. #wrapper) would be replaced by the last stylesheet (i.e. stylesheet-ie.css if loaded with IE 7).
Here's the problem: I successfully load the stylesheet in IE but it's not replacing all the styles. It's still using the styles from stylesheet.css.
Now, this is a VERY simple question but I'm a bit confused (and it probably sounds harder than it is).
Anyway any suggestions is highly appreciated!!
Thank you!

Julian Jorgensen
03-11-2009, 02:03 PM
Sorry never mind, I figured it out! ... For reference:
It WAS actually loading the stylesheet (for IE) but even though a style has exact same name, the inside (e.g. margin-right:10px) will still load if the IE doesn't have it.
Have a great day!

Eoin_
03-12-2009, 12:34 PM
I think there is a way to clear all existing styles, so it won't inherit ones declared elsewhere, but not 100% sure about that.

mwatkins
03-12-2009, 01:58 PM
Search on line for "CSS reset"
Quite frankly I find the use of conditional includes for IE to be more pain than its worth. I always find another way now, or let the IE users suffer a slightly degraded look.
Life is too short.