user1269625
user1269625

Reputation: 3209

HTML CSS IE7 Condional Codes

I have these HTML conditional codes for IE 7 yet they don't appear to be working.

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

<link rel="stylesheet" type="text/css" href="/css/styles.css" />

is there something wrong with them or something I am missing?

Upvotes: 1

Views: 83

Answers (3)

Zeta
Zeta

Reputation: 105975

If you adjust your rules for IE7 in stylesie.css, then it should be loaded after your original css file:

<link rel="stylesheet" type="text/css" href="/css/styles.css" />

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

Rules for a selector with the same specificity will overwrite old ones, so IE7 will parse stylesie.css first and overwrite those rules with the ones from styles.css.

Basic example of this behavior:

div, div.red{
    color:red;
}
div{
    color:blue;
}

This will result in a blue color in all <div>, except the one tagged with the class red.

Upvotes: 4

Circuit Circus
Circuit Circus

Reputation: 161

I guess the position you inserted it is the issue. Your page first loads IE-definitions, then adds your CSS supposed to be the "default" one for all browsers. Now if there are definitions for the same elements like in your IE-Version, that will simply override those.

Upvotes: 0

Nubok
Nubok

Reputation: 3669

From the given information I can only try to guess: for me it looks that "/css/styles.css" overwrites some CSS properties of "/css/stylesie.css" since included after. So I'd try to include it before:

<link rel="stylesheet" type="text/css" href="/css/styles.css" />

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

Upvotes: 0

Related Questions