19 Feb, 2009
Conditional IE Comments (to detect IE browser / IE browser version)
Web Development » Tutorials » Conditional IE Comments (to detect IE browser / IE browser version)
Code:
<!--[if IE 6]>
Internet Explorer 6
<![endif]-->
<!--[if IE 7]>
Internet Explorer 7
<![endif]-->
<!--[if lt IE 7]>
A version of Internet Explorer which is older than 7
<![endif]-->
<!--[if gt IE 6]>
A version of Internet Explorer which is newer than 6
<![endif]-->
<!--[if gte IE 7]>
A version of Internet Explorer which is 7 and above (IE 7, IE 8, etc)
<![endif]-->
Usage:
These comments can be put inside <head> section to load appropriate css/javascript files or inside <body> to display appropriate text.
Example:
<!--[if IE]>
<link rel="stylesheet" type="text/css" href="css/style-ie.css" />
<![endif]-->
The above code ensures that style-ie.css file (css override for IE) is loaded only for IE browsers.
Other similiar posts that you might be interested in:
- Making a website iPhone-friendly using CSS
- Browser Market Share (Year 2009)
- Some simple but effective CSS rules for IE 6
- MutipleIE – Install multiple versions of IE on one computer
- 10 Useful jQuery Snippets
- How to customise WordPress Admin Login page
- Framebar (like diggbar) example in html and css with no javascript






