Syntax
The syntax for conditional comments is as follows:
- Positive
<!--[if condition]> HTML <![endif]-->
- Negative
<!--[if !condition]><![IGNORE[-->
<![IGNORE[]]>
HTML<!--<![endif]-->
IE
- Any version of IE
lt IE version
- Versions less than version
lte IE version
- Versions less than or equal to version
IE version
- Only version version
gte IE version
- Versions greater than or equal to version
gt IE version
- Versions greater than version
version is the version of Internet Explorer, typically
5
, 5.5
, 6
, or 7
HTML is the HTML to be included if the condition does or doesn't match, depending on the type of conditional comment. When included, the HTML is placed right where the conditional comment is in the source.
For negative conditions,
<![IGNORE[-->
<![IGNORE[]]>
can be replaced with -->
if the condition is simply IE
. The longer version is only needed when Internet Explorer might parse the contents.
The
<![IGNORE[ ... ]]>
directive is not available in XML, so it is illegal to use it in XHTML. A solution would be to split it up into two special conditional comments: <!--[if !condition]> XHTML <![endif]-->
<!--[if !IE]>-->
XHTML <!--<![endif]-->
where XHTML is the same both places. Note that Internet Explorer 7 and below don't yet recognize XHTML as a form of XML, so this is merely forward-looking.
Không có nhận xét nào:
Đăng nhận xét