Conditional stylesheet for various version of Internet Explorer (IE)

Posted: May 8, 2011 in CSS, HTML
Tags: ,

Sometime we searching the conditional stylesheet for Internet Explorer (IE) for various version and me too :D. Today I write in my blog about that I hope it will be so helpful to all web developers and of course me :D.Because this blog is my note book.

This would go in your <head> with all the other regular CSS <link>ed CSS files. The opening and closing tags should be familiar, that’s just regular ol’ HTML comments. Then between the brackets, “IF” and “IE” should be fairly obvious. The syntax to note is “!” stand for “not”, so !IE means “not IE”. gt means “greater than”, gte means “greater than or equal”, lt means “less than”, lte means “less than or equal.”

Target ALL VERSIONS of IE

<!--[if IE]>
<link rel="stylesheet" type="text/css" href="all-ie-only.css" /> 
<![endif]-->

Target everything EXCEPT IE

<!--[if !IE]><!-->         
<link rel="stylesheet" type="text/css" href="not-ie.css" />  
<!--<![endif]-->

Target IE 7 ONLY

<!--[if IE 7]>         
<link rel="stylesheet" type="text/css" href="ie7.css"> 
<![endif]-->

Target IE 6 ONLY

<!--[if IE 6]>         
<link rel="stylesheet" type="text/css" href="ie6.css" /> 
<![endif]--> 

Target IE 5 ONLY

<!--[if IE 5]>         
<link rel="stylesheet" type="text/css" href="ie5.css" /> 
<![endif]-->

Target IE 5.5 ONLY

<!--[if IE 5.5000]> 
<link rel="stylesheet" type="text/css" href="ie55.css" /> 
<![endif]--> 

Target IE 6 and LOWER

<!--[if lt IE 7]>         
<link rel="stylesheet" type="text/css" href="ie6-and-down.css" /> 
<![endif]-->
<!--[if lte IE 6]>
 <link rel="stylesheet" type="text/css" href="ie6-and-down.css" /> 
<![endif]--> 

Target IE 7 and LOWER

<!--[if lt IE 8]>       
<link rel="stylesheet" type="text/css" href="ie7-and-down.css" /> 
<![endif]-->
<!--[if lte IE 7]> 
<link rel="stylesheet" type="text/css" href="ie7-and-down.css" /> 
<![endif]--> 

Target IE 8 and LOWER

<!--[if lt IE 9]>         
<link rel="stylesheet" type="text/css" href="ie8-and-down.css" />
<![endif]-->
<!--[if lte IE 8]>
<link rel="stylesheet" type="text/css" href="ie8-and-down.css" />  
<![endif]-->

Target IE 6 and HIGHER

<!--[if gt IE 5.5]>         
<link rel="stylesheet" type="text/css" href="ie6-and-up.css" /> 
<![endif]-->

<!--[if gte IE 6]> <link rel="stylesheet" type="text/css" href="ie6-and-up.css" /> <![endif]-->

Target IE 7 and HIGHER

<!--[if gt IE 6]>         
<link rel="stylesheet" type="text/css" href="ie7-and-up.css" />
<![endif]-->
<!--[if gte IE 7]> 
<link rel="stylesheet" type="text/css" href="ie7-and-up.css" /> 
<![endif]-->

Target IE 8 and HIGHER

<!--[if gt IE 7]>        
<link rel="stylesheet" type="text/css" href="ie8-and-up.css" /> 
<![endif]-->
<!--[if gte IE 8]> 
<link rel="stylesheet" type="text/css" href="ie8-and-up.css" /> 
<![endif]-->
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s