Harsh Baid
Harsh Baid

Reputation: 7249

CSS not affecting that is written for IE browser only

Why I am not able to apply an css that is for IE browser only, I am trying to do it as below with in-page css block.

<style type="text/css">
    <!--[if IE]>
        body a {font-size:12px;text-decoration:none;}
    <![endif]-->
<style>

Reference link

Upvotes: 1

Views: 331

Answers (2)

Holger
Holger

Reputation: 2271

The way to do it is around a css file reference,

Example:

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

You might be able to do this too:

<!--[if IE]>
     <style type="text/css">
        body a {font-size:12px;text-decoration:none;}
     <style>
<![endif]-->

But it has to be in the html page and not in a css file.

Upvotes: 3

Sotiris
Sotiris

Reputation: 40086

because conditional comments can't be in the style tag. Everything within <style> must be css. Try to wrap the style tag with the conditional comment.

Your code: http://jsbin.com/otidal/edit#preview

Correct code: http://jsbin.com/otidal/2/edit#preview

Upvotes: 2

Related Questions