Posted By

paul66 on 01/27/11


css ie hacks bodytag

Versions (?)

Conditional body tag

 / Published in: HTML


This snippet is a Paul Irish original, and allows you to target IE browsers specifically without having to add in an extra http request with another separate stylesheet. Basically, depending on the IE browser that the user is using, a class is added to the body tag. If the user is not using IE, then a classless body tag is used. This allows you to target specific browsers in your css without having to use css hacks, or further stylesheets.

  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)]><!--> <!--<![endif]-->

Report this snippet  

You need to login to post a comment.