Forum Moderators: not2easy
Is it possible to include a "If IE" statement in the stylesheet itself? And how would you do this?
I am wondering about this because I only have one style tag which I need to be different for IE6 and lower.
So for conditional comments you need to be able to add <head> elements: e.g.:
<head>
...
<link rel="stylesheet" type="text/css" href="/style.css" />
<!--[if IE 6]>
<link rel="stylesheet" type="text/css" href="/ie6.css" />
<![endif]-->
<!--[if IE 7]>
<link rel="stylesheet" type="text/css" href="/ie7.css" />
<![endif]-->
...
</head>
If you don't want to override some of your css, but instead want totally different css, it too can be achieved by conditional comments, (but it's nasty as it's actually serving invalid html to standards compliant browsers).
E.g.: IE won't touch this stylesheet:
<![if !IE]>
<link rel="stylesheet" type="text/css" href="/style.css" />
<![endif]>
If you only want one CSS file to be served depending on what browser you see and are ready to deal with cloaked browsers, proxies and potential consequences for beign considered "cloaking" [you will serve e.g. GoogleBot different content from your average visitor!]
Then you can try to detect the browse and deliver content based on that. [Not something I'm willing to do]