LOADING ...
Conditional Comments allow web developers to show or hide HTML code based on the version of the Internet Explorer browser used by viewers. Conditional Comments are supported by IE only (version 5 or greater), but can still be useful for other browsers as it can be used to indicate separate HTML codes to be processed, one set for IE and the other for non-IE.
This is an important feature as different browser types or versions process the same code in a different way, hence give different results. So, web developers may need to provide different codes for each browser types or version in order achieve the same or similar results. For example, IE version 6 or less does not support PNG image display by using the default IMG tag. Instead, it requires additional tag to make use of filter AlphaImageLoader. See more in PNG Transparency in Web Design article.
Code for IE<!--[if IE]>
Insert HTML code here.
This code can be processed only by IE (version 5+).
<![endif]-->
Code for non-IE<![if !IE]>
Insert HTML code here.
IE 5+ will not process this code.
Non-IE will process this code.
<![endif]>
This is recommended by Microsoft for when the content should be exposed to non-IE browsers. Microsoft acknowledges this method is not standardized markup for comments, intending these tags to be overlooked by other browsers and expose the content in the middle. Some web developers use an alternative technique for non-IE conditional comments in order to only use standardize markup.<!--[if !IE]>-->
Insert HTML code here.
IE 5+ will not process this code.
Non-IE will process this code.
<!--
IE Version
Conditional Comments can be used to assign specific codes for specific IE version. Example:<!--[if IE 7]>
You are using IE 7!
<![endif]-->
A combination of feature, operator, and/or value can be used to form a conditional expression, as shown in the following table.Item Example Comment IE [if IE] The only currently supported feature is the string "IE", corresponding to Internet Explorer. value [if IE 7] An integer or floating point numeral corresponding to the version of the browser. Returns a Boolean value of true if the version number matches the browser version. ! [if !IE] The NOT operator. This is placed immediately in front of the feature, operator, or expression to reverse the Boolean meaning of the expression. lt [if lt IE 5.5] The less-than operator. Returns true if the first argument is less than the second argument. lte [if lte IE 6] The less-than or equal operator. Returns true if the first argument is less than or equal to the second argument. gt [if gt IE 5] The greater-than operator. Returns true if the first argument is greater than the second argument. gte [if gte IE 7 The greater-than or equal operator. Returns true if the first argument is greater than or equal to the second argument. ( ) [if (IE 7)] Subexpression operators. Used in conjunction with boolean operators to create more complex expressions. & [if (gt IE 5)&(lt IE 7)] The AND operator. Returns true if all subexpressions evaluate to true. | [if (IE 6)|(IE 7)] The OR operator. Returns true if any of the subexpressions evaluates to true. true [if true] Always evaluates to true. false [if false] Always evaluates to false.
External Reference
Wednesday, 15 August 2007
Subscribe to:
Post Comments (Atom)
0 Comments:
Post a Comment