Posted By

f6design on 10/01/10


css ie html conditional-comments

Versions (?)

Who likes this?

2 people have marked this snippet as a favorite


Apply IE-specific class to body tag instead of using conditional stylesheets

 / Published in: HTML


Instead of feeding IE separate stylesheets, use conditional comments to apply an IE-specific class to the body tag. This means all your IE-only classes can go in your main stylesheet, e.g. .ie6 .myelement { margin:5px; }\r\n\r\nThis was taken from the HTML5 Boilerplate.

  1. <!--[if lt IE 7 ]> <body class="ie6"> <![endif]-->
  2. <!--[if IE 7 ]> <body class="ie7"> <![endif]-->
  3. <!--[if IE 8 ]> <body class="ie8"> <![endif]-->
  4. <!--[if IE 9 ]> <body class="ie9"> <![endif]-->
  5. <!--[if (gt IE 9)|!(IE)]><!--> <body> <!--<![endif]-->D

Report this snippet  

You need to login to post a comment.