Solved

Conditional CSS

Posted on 2011-02-24
3
219 Views
Last Modified: 2012-05-11
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
Comment
Question by:milani_lucie
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 4

Expert Comment

by:LAMASE
ID: 34974336
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
 
LVL 4

Accepted Solution

by:
LAMASE earned 500 total points
ID: 34974360
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
 
LVL 83

Expert Comment

by:Dave Baldwin
ID: 34974436
@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

Industry Leaders: 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!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article explains how to prepare an HTML email signature template file containing dynamic placeholders for users' Azure AD data. Furthermore, it explains how to use this file to remotely set up a department-wide email signature policy in Office …
Finding original email is quite difficult due to their duplicates. From this article, you will come to know why multiple duplicates of same emails appear and how to delete duplicate emails from Outlook securely and instantly while vital emails remai…
In this tutorial viewers will learn how to style a corner ribbon overlay for an image using CSS Create a new class by typing ".Ribbon":  Define the class' "display:" as "inline-block": Define its "position:" as "relative": Define its "overflow:" as …
HTML5 has deprecated a few of the older ways of showing media as well as offering up a new way to create games and animations. Audio, video, and canvas are just a few of the adjustments made between XHTML and HTML5. As we learned in our last micr…

696 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question