If IE works only for style sheets?

advertisements

So I am forced to use conditional style for IEs via the [if IE] comment. I have been trying to fit it in my code but I found some inconsistency that I cant explain.

If I use it like this

<!--[if IE]>
<style type="text/css">
    #SomeName {
        width: 100em;
    }
</style>
<![endif]-->

it will just not work.

However, if I put the style in a css sheet and add a link to it, it works.

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

Is there a way for me to put the style inside the [if IE] tags rather than linking it through the tag? it just looks wrong.

Thank in adavance


Nothing wrong with your code.

Make sure that #SomeName is as such in the html (beacuse css rules are case-sensitive), and make sure that you include your code after the normal css include (to avoid having the rule overriden by what is in the normal css)