• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 225
  • Last Modified:

Conditional CSS

Hi,

I have the following code:

<html>

      <head>

            <style type="text/css">

            body
            {
                   [if IE] background-color : blue;
                   [if Gecko] background-color : red;
            }

            </style>

      </head>

      <body>

            <form name="form1">

            </form>

      </body>

</html>

It is not working as expected in IE 6.0. Can you please FIX this ?

Thanks
0
milani_lucie
Asked:
milani_lucie
  • 2
1 Solution
 
LAMASECommented:
I don't know if IE6 supports that kind of styling... it seems that you need to install something for have that styles working
http://www.conditional-css.com/usage

try this, calling different styles in head section

<!--[if !IE]><!-->  
  <style type="text/css">@import '/media/css/c-css.php?b=nonIE';</style>  
<!--<![endif]-->  
<!--[if IE 6]>  
  <style type="text/css">@import '/media/css/ic-css.php?b=IE&v=6';</style>  
<![endif]-->  
<!--[if gte IE 7]>  
  <style type="text/css">@import '/media/css/c-css.php?b=IE&v=7';</style>  
<![endif]-->  

Open in new window


Keep in mind that you can make everything in a common css file, then include different "patch" css files for different browsers.
0
 
LAMASECommented:
Sorry, I pasted the wrong example
<!--[if lte IE 7]>
<link rel="stylesheet" type="text/css" href="ie7.css" />
<![endif]-->
<!--[if lte IE 6]>
<link rel="stylesheet" type="text/css" href="ie6.css" />
<![endif]-->

Open in new window

0
 
Dave BaldwinFixer of ProblemsCommented:
@LAMASE's examples are correct.  The conditional statements are in the HTML file and can control loading of additional CSS files but the conditional statements do Not work inside the CSS declarations or files.  In addition, only IE will recognize them.  Using [if Gecko] has no effect, Mozilla and Webkit browsers do not recognize such things.
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now