We Recommend

CSS: The Definitive Guide CSS: The Definitive Guide
Provides you with a comprehensive guide to CSS implementation, along with a thorough review of all aspects of CSS 2.1. Updated to cover Internet Explorer 7, Microsoft's vastly improved browser, this new edition includes content on positioning, text wrapping (nowrap), lists and generated content, table layout, user interface, paged media, and more.


Posted By

aznprncritic on 02/04/07


Tagged

css ie6 conditional internet explorer ie5 ie7 comments browsers


Versions (?)


Who likes this?

7 people have marked this snippet as a favorite

Hirmine
basicmagic
chrisaiv
gtcaz
mountchuck
shellydennison
SpinZ


Use Conditional Comments to Subjugate IE


Published in: CSS 


Over 90% of the bugs front-end developers have to resolve deal with the various versions of Internet Explorer and their varying support for standards. So instead of having to resort to CSS hacks, why not just keep 'em separated: use Microsoft's propriety conditional comments to insert css files that only IE will see. The example below illustrates how to serve one stylesheet to IE5, IE5.5 and IE6 and another stylesheet for IE7.

  1. <!--[if lt IE 7]>
  2. <link href="cmn/css/ie.css" rel="stylesheet" type="text/css" media="screen" />
  3. <![endif]-->
  4.  
  5. <!--[if IE 7]>
  6. <link href="cmn/css/ie7.css" rel="stylesheet" type="text/css" media="screen" />
  7. <![endif]-->

Report this snippet 

Comments

RSS Icon Subscribe to comments
Posted By: chrisaiv on May 21, 2008

Thank you for the introduction.

For those like me who are interested in finding out how to target every version of IE, this link may be of help. http://www.positioniseverything.net/articles/multiIE.html

You need to login to post a comment.