Conditional comment

Conditional Comments (abbreviated CC, for English: conditional comments ) are control structures in HTML documents that can be interpreted only by Microsoft Internet Explorer and programs from the Microsoft Office series (eg Microsoft Word). They offer the possibility to execute depending on the program version of an HTML renderer, different HTML. From the Internet Explorer 10 browser, this form of crossover for standards-compliant HTML pages is no longer supported.

HTML syntax

The use is analogous to real HTML comments (<- comment -> ):

< - [ if ' condition '] > instructions < [ endif] ->

Internet Explorer checks the formulated condition and interprets the content, when the condition is true. It is possible by default comparison operators and values ​​to address different versions of the browser. Other user agents interpret this structure as syntactically correct comment and ignore the content.

When using the standards-compliant mode is omitted in Internet Explorer version 10 the opportunity to use conditional comments. The construct is then also only treated as a comment.

Values ​​(selection)

If it becomes necessary conditions can also be stapled.

Operators

Reversal

Usually, conditional comments to hide instructions before user agents that do not understand this. Microsoft refers to this " downlevel -hidden ", ie " before older browsers hidden " comments. This effect can also be reversed (so-called " downlevel -revealed " - comments):

instructions for IE before version 7 and other browsers

This is no longer an HTML comment, but syntactically incorrect and thus invalides markup. The condition in question is evaluated only by Internet Explorer. Other browsers interpret the strings and as invalid tags and provide only the content between dar. Syntactically correct and valid according to W3C is the following syntax:

< - [if lt IE 7]> instructions for IE prior to version 7 < - < [ endif ] ->

To execute code in Internet Explorer <10 and to integrate an alternate code for other browsers, the following variant is. Since alternative Brower can not do anything with conditional comments, the code for the alternate browser may not be within a comment, but should be only between two comments:

<- [IF IE ]! > This content is executed by the Internet Explorer up to version 10 < [ ENDIF ] ->   < - [IF IE ]> -> This content is reviewed by all other browsers running < - < [ ENDIF ] -> Importance for Outlook 2007

The representation of e- mails in HTML format in Outlook 2007 is Word not taken more of a component of Internet Explorer, but Microsoft. In addition, for safety reasons different HTML features ( such as forms or scripts) Outlook 2007 is not available. The display of HTML e -mail can be adjusted by using conditional comments for Outlook to offer an alternative to an input form, for example, with newsletters.

< - [ if gte mso 12 ]> instructions for Office 2007 and greater than < [ endif] ->

Since Internet Explorer 4 (JScript 3.0) there is a similar mechanism for JavaScript. The JScript interpreter used in IE evaluates the following syntax that is recognized by other interpreters only as a comment. Microsoft calls the behavior " conditional compilation ".

Vector Markup Language Microsoft Developer Network

199868
de