Harshana
Harshana

Reputation: 7647

Conditional comments for CSS in IE9

I want to add a specific style sheet for IE9 which overrides the img.icon css class with different margin values. So i add the below in the head section. But when page loads it display as a text in browser.

 <!--[if IE 9]>
    img.icon {
        float: right;
        margin: 4px -31px;
    }
    <![endif]-->

Upvotes: 0

Views: 63

Answers (3)

user3265259
user3265259

Reputation:

You are missing the <style> tags

<!--[if IE 9]>
<style>
    img.icon {
        float: right;
        margin: 4px -31px;
    }
</style>
<![endif]-->

Upvotes: 2

Leon
Leon

Reputation: 2149

You forgot the style tags.

<!--[if IE 9]>
<style>
    img.icon {
        float: right;
        margin: 4px -31px;
    }
</style>
<![endif]-->

Also, you might find it easier to load an external stylesheet within the conditional comments:

<!--[if IE 9]>
<link rel="stylesheet" href="css/ie9.css">
<![endif]-->

Upvotes: 0

Carol McKay
Carol McKay

Reputation: 2424

 <!--[if IE9]>
<style>
    img.icon {
        float: right;
        margin: 4px -31px;
    }
</style>
    <![endif]-->

it think

Upvotes: 0

Related Questions