Posted By

michellebracken on 08/18/11


Tagged


Versions (?)

Who likes this?

1 person have marked this snippet as a favorite

spee66


Conditional Comments


 / Published in: CSS
 

Conditional commentsare an ideal way to target IE browsers only, since IE is often the browser that won’t cooperate. The basic form of a conditional comments is:

The above will load an IE specific stylesheet only when the browser viewing the page is Internet Explorer. You can further target specific versions of IE. You can specify any version of Internet Explorer and through a combination of conditional comments you can server different CSS styles to different versions of IE.

  1. 1 <!--[if IE]>
  2. 2 <link rel="stylesheet" type="text/css" href="ie-stylesheet.css" />
  3. 3 < ![endif]-->
  4.  
  5.  
  6. 1 <!--[if IE 6]> - targets IE6 only -->
  7. 2 <!--[if gt IE 6]> - targets IE7 and above -->
  8. 3 <!--[if lt IE 6]> - targets IE5.5 and below -->
  9. 4 <!--[if gte IE 6]> - targets IE6 and above -->
  10. 5 <!--[if lte IE 6]> - targets IE6 and below -->

Report this snippet  

You need to login to post a comment.