Link to home
Start Free TrialLog in
Avatar of John Carney
John CarneyFlag for United States of America

asked on

Conditional statement that switches style sheets in a web page

I need a conditional statement for IE6 (and lower) in the header of my web page that will switch style sheets from the default style1.css to style2.css.

Thanks,

John
ASKER CERTIFIED SOLUTION
Avatar of David S.
David S.
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of John Carney

ASKER

Okay, here's my real-life example. This particular page has 4 style sheets. My "ie_styles.css" might have to have overrides of all 4 of them. I suppose that's not a problem as long as I put it last, right?

For that matter can you put the IE6 conditional statements in the css itself so that
     background: url(images/image1.png);
          could be replaced with this in IE6:
     background: url(images/image2.jpg);
or whatever

If so, how would that be stated exactly?

Thanks.


<link href="/css/global.css" rel="stylesheet" type="text/css" />
<link href="css/greenStuff.css" rel="stylesheet" type="text/css" />
<link href="css/dimensions_index.css" rel="stylesheet" type="text/css" />
<link href="css/SimpleDropdown.css" rel="stylesheet" type="text/css" />
<!--[if lte IE 6]><link rel="stylesheet" type="text/css" href="css/ie_styles.css" /><![endif]-->

Open in new window

Thanks. If you can, please let me know the proper syntax for overriding a particular style within the css itself, assuming that's something that can be done.
-John
You just make another rule that has the same selector as the first rule. Wherever there is more than one declaration for the same property in rules that have the same the specificity, the last declaration is the one that will be used, unless overridden by a rule that has a higher specificity.

In short, the cascade is a wonderful thing.