cssconditional-comments

Conditional Statement add css in them


Is it possible to do the following with conditional comments:

<!--[if IE]>
   .ie-only{margin-top:-13px;}
<![endif]-->

Solution

  • You can do like this...

    <html>
    
    <head>
      <!--[if IE]>
      <style>
        .box {  
            width: 500px;  
            background:red;
            padding: 100px 0;  
          }  
      </style>
    <![endif]-->
    </head>
    
    <body>
      <div class="box">Try this in IE</div>
    </body>
    
    </html>

    EDIT:

    You can also include external css for IE alone.

    <!--[if IE]>
        <link rel="stylesheet" type="text/css" href="onlyfoie.css" />
    <![endif]-->