Hello
This post may be something very common and very known, however not everyone knows these, so this post may be useful to someone.
Here is an entire list for this
<!--[IF IE 6]> <![endif]--> this means that everything between those will only be loaded/visible by Internet Explorer 6
<!--[IF lte/lt/gte/gt IE 6]> <![endif]--> this means that depending on the legend it will load things like
<!--[IF !IE]>--> <!--<![endif]--> this means that all versions of IE will NOT READ the code between those 2
lines. This is extremely useful when you try to load specific information and u do not want IE to load it, but
all the other browsers to load said that information. for example
<!--[IF !IE]>--> THIS LINE WILL NOT BE READ BY IE BROWSERS <!--<![endif]-->
- lte = Lower Than Or Equal — lte IE6 means that will be loaded by IE6 and lower versions like IE5.5 / 5 and so on and so forth.
- lt = Lower Than — lt IE6 means that only lower versions of Internet Explorer 6 will read that part of the code such as IE5.5 / IE5 / IE4 and so on and so forth.
- gte = Greater Than Or Equal — gte IE6 means that browsers versions higher than 6 or equal to 6 will load that code, such as IE6 / IE7 / IE8 and so on and so forth.
- gt = Greater than — gt IE6 means that browsers versions higher than 6 will load the code such as IE7 / IE8 and so on and so forth.
The most useful part is the ability to load information that is not read by IE browsers at all, you could do something very nice, for example if you wish to drop IE6 support your stylesheet and JS includes will look like this:
<!--[IF !IE]>-->
<link rel="stylesheet" type="text/css" href="./css/mainCss.css" />
<!--<![endif]-->
<!--[if gte IE 7]>
<link rel="stylesheet" type="text/css" href="./css/mainCss.css" />
<![endif]-->
<!--[IF !IE]>-->
<script type="text/javascript" src="./js/mainJs.js" />
<!--<![endif]-->
<!--[IF gte IE 7]>
<script type="text/javascript" src="./js/mainJs.js" />
<![endif]-->
The code above will only load the files for IE7+ and all other browsers. A live example of this situation is my own website, which does not support IE6.
Regards
Posted By: Dinulescu Alexandru Adrian
Last Edit: 09 Jan 2010 @ 12:18 AM
Email •
Permalink
Recent Comments