How to write conditional statement in CSS?

 Posted by Raja on 1/9/2009 | Category: CSS 3 Interview questions | Views: 10745
Answer:

Following is the example of conditional statement in CSS.

 <head>

<style type="text/css">
body
{
color:blue;
}
</style>
<!--[if IE 7]>
<style type="text/css">
body {
background-color:red;
}
</style>
<![endif]-->
</head>


If this code will run in IE7 browser, the background color of the page will be red, for other browser it will be default color (white).


Asked In: Many Interviews | Alert Moderator 

Comments or Responses

Login to post response