0

IE Conditional Comments

IE Conditional Comments via @largestartist Posted by Jose Cuadra on February 26, 2009 Tags: | | | Filed Under: References

Years ago before I discovered Internet Explorer’s Conditional Comments, I struggled with CSS hacks, IE filters, and unreliable JavaScript sniffers.
With this technique markup inside the comments will be only visible to the IE browser in general or specific versions that you specify.

To target Internet Explorer in general, singling it out from every other browser, you would use:

<!--[If IE]>
Some content here.
<![endif]-->

To target a specific version of IE, you would use:

<!--[If IE 7]>
Some content here.
<![endif]-->

To target versions of the browser that are 7 and below:

<!--[If lte IE 7]>
Some content here.
<![endif]-->

To target versions of the browser that are 6 and above:

<!--[If gte IE 6]>
Some content here.
<![endif]-->

Want More? Try These.

Related Articles
CFCACHE, IE, CSS and XHTML
Live Markup Editor
Flash Slideshow in Actionscript 3
Web Fonts Suck!
Type Doc Re-Released
Flash Display Fixes
Target Blank for XHTML
Table Behavior without Tables
Random Articles
Flash Display Fixes
Random Functions
Posemaniacs Anatomy
fliteBox Lightbox for Flickr
Web Fonts Suck!
Access Cascading Styles with JavaScript
Funny Superman Shirts
The Definitive List of Vector Art
5 Pointz by Passetti
Color Picker

Leave a Reply