Forum Moderators: not2easy

Message Too Old, No Replies

Conditional css in external files

Possible?

         

madmatt69

8:42 pm on Jan 21, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Hey all,

I've got some conditional IE6 statements like this in the <head> of each of my pages:

<!--[if lte IE6]>
<style>
#right a {height1%;}
#center {margin-top:200px;}
</style>
<![endif]-->

Is it possible to include that in my external style sheet? How would the format of the code change, if at all?

Thanks!

mep00

9:05 pm on Jan 21, 2007 (gmt 0)

10+ Year Member



No, what you posted was HTML, which is invalid in a .css file. What you can do is put the conditional comment in your page's head and, instead of a style block, put a link tag.

madmatt69

2:03 am on Jan 22, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



So instead of:
<!--[if lte IE6]>
<style>
#right a {height1%;}
#center {margin-top:200px;}
</style>
<![endif]-->

You'd have:
<!--[if lte IE6]>
<link href="mystyle.css" rel="stylesheet" type="text/css">
<![endif]-->

and have the code in the mystyle.css?

Setek

2:18 am on Jan 22, 2007 (gmt 0)

10+ Year Member



Yep, that's exactly right :)

All you have to do is have two separate stylesheets, one for every browser, and one just for IE, and define it like that (below the one for every browser's

<link />
) and you're good to go :)