<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
		<id>http://www.knodel.net/oops/index.php?action=history&amp;feed=atom&amp;title=Conditional_comment</id>
		<title>Conditional comment - Revision history</title>
		<link rel="self" type="application/atom+xml" href="http://www.knodel.net/oops/index.php?action=history&amp;feed=atom&amp;title=Conditional_comment"/>
		<link rel="alternate" type="text/html" href="http://www.knodel.net/oops/index.php?title=Conditional_comment&amp;action=history"/>
		<updated>2026-05-08T13:15:46Z</updated>
		<subtitle>Revision history for this page on the wiki</subtitle>
		<generator>MediaWiki 1.26.3</generator>

	<entry>
		<id>http://www.knodel.net/oops/index.php?title=Conditional_comment&amp;diff=306&amp;oldid=prev</id>
		<title>Eogen: 1 revision imported</title>
		<link rel="alternate" type="text/html" href="http://www.knodel.net/oops/index.php?title=Conditional_comment&amp;diff=306&amp;oldid=prev"/>
				<updated>2018-09-19T08:19:00Z</updated>
		
		<summary type="html">&lt;p&gt;1 revision imported&lt;/p&gt;
&lt;table class=&#039;diff diff-contentalign-left&#039;&gt;
				&lt;tr style=&#039;vertical-align: top;&#039; lang=&#039;en&#039;&gt;
				&lt;td colspan=&#039;1&#039; style=&quot;background-color: white; color:black; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan=&#039;1&#039; style=&quot;background-color: white; color:black; text-align: center;&quot;&gt;Revision as of 08:19, 19 September 2018&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&#039;2&#039; style=&#039;text-align: center;&#039; lang=&#039;en&#039;&gt;&lt;div class=&quot;mw-diff-empty&quot;&gt;(No difference)&lt;/div&gt;
&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;</summary>
		<author><name>Eogen</name></author>	</entry>

	<entry>
		<id>http://www.knodel.net/oops/index.php?title=Conditional_comment&amp;diff=305&amp;oldid=prev</id>
		<title>XP1 at 01:03, 11 August 2018</title>
		<link rel="alternate" type="text/html" href="http://www.knodel.net/oops/index.php?title=Conditional_comment&amp;diff=305&amp;oldid=prev"/>
				<updated>2018-08-11T01:03:20Z</updated>
		
		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;&amp;#039;&amp;#039;&amp;#039;Conditional comments&amp;#039;&amp;#039;&amp;#039; are [[Conditional (computer programming)|conditional statements]] interpreted by Microsoft [[Internet Explorer]] versions 5 through 9 in [[HTML]] source code. Conditional comments can be used to provide and hide code to and from Internet Explorer. Conditional comments are no longer supported in IE10 and IE11.&lt;br /&gt;
&lt;br /&gt;
Conditional comments in HTML&amp;lt;ref name=&amp;quot;MS1&amp;quot;&amp;gt;{{cite web| url=http://msdn2.microsoft.com/en-us/library/ms537512.aspx| title=About Conditional Comments| publisher=Microsoft Corporation}}&amp;lt;/ref&amp;gt; first appeared in [[Microsoft]]&amp;#039;s [[Internet Explorer 5]] browser, although support has now been deprecated. In [[Internet Explorer 10]], HTML conditional comments are not supported when the page is in standards mode (document mode 10).&amp;lt;ref&amp;gt;[http://blogs.msdn.com/b/ie/archive/2011/07/06/html5-parsing-in-ie10.aspx Microsoft - HTML5 Parsing in IE10]&amp;lt;/ref&amp;gt; JScript conditional comments were introduced in [[Internet Explorer 4]] and they continue to be supported in [[Internet Explorer 10]], in standards mode or compatibility mode.&lt;br /&gt;
&lt;br /&gt;
==Examples==&lt;br /&gt;
Here is a simple example that demonstrates how conditional comments work.&lt;br /&gt;
&amp;lt;source lang=&amp;quot;html5&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;!--[if IE 6]&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;You are using Internet Explorer 6.&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;![endif]--&amp;gt;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Syntax ==&lt;br /&gt;
There are two types of &amp;quot;conditional comments&amp;quot;: &amp;#039;&amp;#039;downlevel revealed&amp;#039;&amp;#039;, and &amp;#039;&amp;#039;downlevel hidden&amp;#039;&amp;#039;.&lt;br /&gt;
&lt;br /&gt;
The basic syntax of each type of comment is shown in the following table. The first comment shown is the basic HTML Comment, which is included for the purpose of comparison and to illustrate the different syntax used by each type of conditional comment.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Comment type&lt;br /&gt;
! Syntax or possible value&lt;br /&gt;
|-&lt;br /&gt;
| standard HTML comment&lt;br /&gt;
| &amp;amp;lt;!--&amp;amp;nbsp;Comment content &amp;amp;nbsp;--&amp;amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| downlevel-hidden&lt;br /&gt;
| &amp;amp;lt;!--[if &amp;#039;&amp;#039;expression&amp;#039;&amp;#039;]&amp;amp;gt; &amp;#039;&amp;#039;HTML&amp;#039;&amp;#039; &amp;amp;lt;![endif]--&amp;amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| downlevel-revealed&lt;br /&gt;
| &amp;amp;lt;![if &amp;#039;&amp;#039;expression&amp;#039;&amp;#039;]&amp;amp;gt; &amp;#039;&amp;#039;HTML&amp;#039;&amp;#039; &amp;amp;lt;![endif]&amp;amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
The &amp;#039;&amp;#039;HTML&amp;#039;&amp;#039; shown inside the syntax block in each of the conditional comments denotes any block of HTML content, including script. Both types of conditional comment use a conditional &amp;#039;&amp;#039;expression&amp;#039;&amp;#039; to indicate whether the content inside the comment block should be parsed or ignored. The conditional expression is formed from a combination of feature, operator, and/or value, depending on the feature.  The following table shows the supported features and describes the values each feature supports.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Item&lt;br /&gt;
! Example&lt;br /&gt;
! Comment&lt;br /&gt;
|-&lt;br /&gt;
| IE&lt;br /&gt;
| [if IE]&lt;br /&gt;
| The string &amp;quot;IE&amp;quot; is a &amp;#039;&amp;#039;feature&amp;#039;&amp;#039; corresponding to the version of Internet Explorer used to view the Web page.&lt;br /&gt;
|-&lt;br /&gt;
| value&lt;br /&gt;
| [if IE 7]&lt;br /&gt;
| An integer or floating point numeral corresponding to the &amp;#039;&amp;#039;version&amp;#039;&amp;#039; of the browser. Returns a Boolean value of true if the version number matches the browser version. For more information, see [[Version vector]]s.&lt;br /&gt;
|-&lt;br /&gt;
| WindowsEdition&lt;br /&gt;
| [if WindowsEdition]&lt;br /&gt;
| Internet Explorer 8 on Windows 7. The string &amp;quot;WindowsEdition&amp;quot; is a &amp;#039;&amp;#039;feature&amp;#039;&amp;#039; corresponding to the edition of Microsoft Windows used to view the Web page.&lt;br /&gt;
|-&lt;br /&gt;
| value&lt;br /&gt;
| [if WindowsEdition 1]&lt;br /&gt;
| An integer corresponding to the &amp;#039;&amp;#039;edition&amp;#039;&amp;#039; of Windows used to view the Web page. Returns a Boolean value of true if the value matches the edition being used. For information about supported values and the editions they describe, see the &amp;#039;&amp;#039;pdwReturnedProductType&amp;#039;&amp;#039; parameter of the GetProductInfo function.&lt;br /&gt;
|-&lt;br /&gt;
| true&lt;br /&gt;
| [if true]&lt;br /&gt;
| Always evaluates to true.&lt;br /&gt;
|-&lt;br /&gt;
| false&lt;br /&gt;
| [if false]&lt;br /&gt;
| Always evaluates to false.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
The following table describes the operators that can be used to create conditional expressions.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Item&lt;br /&gt;
! Example&lt;br /&gt;
! Comment&lt;br /&gt;
|-&lt;br /&gt;
|!&lt;br /&gt;
| [if !IE]&lt;br /&gt;
| The NOT operator. This is placed immediately in front of the &amp;#039;&amp;#039;feature&amp;#039;&amp;#039;, &amp;#039;&amp;#039;operator&amp;#039;&amp;#039;, or &amp;#039;&amp;#039;subexpression&amp;#039;&amp;#039; to reverse the Boolean meaning of the expression.&lt;br /&gt;
|-&lt;br /&gt;
| lt&lt;br /&gt;
| [if lt IE 5.5]&lt;br /&gt;
| The less-than operator. Returns true if the first argument is less than the second argument.&lt;br /&gt;
|-&lt;br /&gt;
| lte&lt;br /&gt;
| [if lte IE 6]&lt;br /&gt;
| The less-than or equal operator. Returns true if the first argument is less than or equal to the second argument.&lt;br /&gt;
|-&lt;br /&gt;
| gt&lt;br /&gt;
| [if gt IE 5]&lt;br /&gt;
| The greater-than operator. Returns true if the first argument is greater than the second argument.&lt;br /&gt;
|-&lt;br /&gt;
| gte&lt;br /&gt;
| [if gte IE 7]&lt;br /&gt;
| The greater-than or equal operator. Returns true if the first argument is greater than or equal to the second argument.&lt;br /&gt;
|-&lt;br /&gt;
| ( )&lt;br /&gt;
| [if !(IE 7)]&lt;br /&gt;
| Subexpression operators. Used in conjunction with boolean operators to create more complex expressions. &lt;br /&gt;
|-&lt;br /&gt;
| &amp;amp;amp;&lt;br /&gt;
| [if (gt IE 5)&amp;amp;amp;(lt IE 7)]&lt;br /&gt;
| The AND operator. Returns true if all subexpressions evaluate to true&lt;br /&gt;
|-&lt;br /&gt;
| &amp;amp;#124;&lt;br /&gt;
| [if (IE 6)&amp;amp;#124;(IE 7)]&lt;br /&gt;
| The OR operator. Returns true if any of the subexpressions evaluates to true.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===Downlevel-hidden conditional comment===&lt;br /&gt;
&lt;br /&gt;
Below are two examples of a &amp;quot;downlevel hidden&amp;quot; conditional comment:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;html5&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;!--[if IE 8]&amp;gt;&lt;br /&gt;
&amp;lt;link href=&amp;quot;ie8only.css&amp;quot; rel=&amp;quot;stylesheet&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;![endif]--&amp;gt;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
or&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;html5&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;!--[if lte IE 7]&amp;gt;&lt;br /&gt;
&amp;lt;style type=&amp;quot;text/css&amp;quot;&amp;gt;&lt;br /&gt;
/* CSS here */&lt;br /&gt;
&amp;lt;/style&amp;gt;&lt;br /&gt;
&amp;lt;![endif]--&amp;gt;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The directive in the first example will let IE 8 read the specified CSS file, while IE 7 or older IE versions will ignore it. Browsers other than IE will also ignore it because it looks like a standard HTML comment. The tag in the second example will let IE versions 5.0 through 7 read the internal CSS style. With different uses of this tag you can also single out IE 6, IE 5, or versions of IE that are newer (greater) or older (less) than a specified version.&lt;br /&gt;
&lt;br /&gt;
===Downlevel-revealed conditional comment===&lt;br /&gt;
&lt;br /&gt;
Below is an example of a &amp;quot;downlevel revealed&amp;quot; conditional &amp;#039;comment&amp;#039;, which is &amp;#039;&amp;#039;not an (X)HTML&amp;#039;&amp;#039; comment at all, despite the misleading name,  using the default Microsoft syntax:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;html5&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;![if !IE]&amp;gt;&lt;br /&gt;
&amp;lt;link href=&amp;quot;non-ie.css&amp;quot; rel=&amp;quot;stylesheet&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;![endif]&amp;gt;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This example shows content that should be exposed only to non-IE browsers, as the condition evaluates to &amp;quot;false&amp;quot; on IE (and hence the content is ignored), while the tags themselves are unrecognized (and hence ignored) on non-IE browsers. This is not valid HTML or XHTML.&lt;br /&gt;
&lt;br /&gt;
Microsoft acknowledges this syntax is not standardized markup,&amp;lt;ref&amp;gt;{{cite web|url=http://msdn.microsoft.com/workshop/author/dhtml/overview/ccomment_ovw.asp|archive-url=http://arquivo.pt/wayback/20080315163046/http://msdn.microsoft.com/workshop/author/dhtml/overview/ccomment_ovw.asp|dead-url=yes|archive-date=2008-03-15|title=MSDN — About Conditional Comments|accessdate= 2007-01-03|author=|date=|work=|publisher=}}&amp;lt;/ref&amp;gt; intending these tags to be overlooked by other browsers and expose the content in the middle. In order to ensure compliance with W3C standards, some web developers use an alternative technique&amp;lt;ref&amp;gt;[http://www.456bereastreet.com/archive/200511/valid_downlevelrevealed_conditional_comments/ Valid downlevel-revealed conditional comments {{pipe}} 456 Berea Street]&amp;lt;/ref&amp;gt; for downlevel-revealed conditional comments:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;html5&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;!--[if !IE]&amp;gt;--&amp;gt;&lt;br /&gt;
&amp;lt;link href=&amp;quot;non-ie.css&amp;quot; rel=&amp;quot;stylesheet&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;!--&amp;lt;![endif]--&amp;gt;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
While somewhat confusing in structure, this specific syntax is valid (X)HTML and is useful for conditional sections intended specifically for non-IE browsers; if the condition evaluates to &amp;#039;&amp;#039;true&amp;#039;&amp;#039; (for example, if writing code meant to display on non-IE browsers &amp;#039;&amp;#039;and&amp;#039;&amp;#039; on some versions of IE), IE will then display the &amp;quot;--&amp;gt;&amp;quot; present before the HTML content.  This problem is easily solved by prepending &amp;quot;&amp;lt;!&amp;quot; to the initial &amp;quot;--&amp;gt;&amp;quot; as follows:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;html5&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;!--[if gt IE 6]&amp;gt;&amp;lt;!--&amp;gt;&lt;br /&gt;
This code displays on non-IE browsers and on IE 7 or higher.&lt;br /&gt;
&amp;lt;!--&amp;lt;![endif]--&amp;gt;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
The extra &amp;quot;&amp;lt;!&amp;quot; is ignored by non-IE browsers; it is also ignored by IE regardless of the condition because if &amp;#039;&amp;#039;false&amp;#039;&amp;#039;, everything within the conditional comment is ignored, and if &amp;#039;&amp;#039;true&amp;#039;&amp;#039;, the resulting tag &amp;lt;code&amp;gt;&amp;lt;nowiki&amp;gt;&amp;lt;!--&amp;gt;&amp;lt;/nowiki&amp;gt;&amp;lt;/code&amp;gt; is unrecognized and therefore ignored.&lt;br /&gt;
&lt;br /&gt;
=== Conditional comments in JScript ===&lt;br /&gt;
Starting with Internet Explorer 4, there exists a similar proprietary mechanism for adding conditional comments  within [[JScript]], known as conditional compilation.&amp;lt;ref name=&amp;quot;MS2&amp;quot;&amp;gt;{{cite web&lt;br /&gt;
| url       = http://msdn2.microsoft.com/en-us/library/ahx1z4fs(VS.80).aspx&lt;br /&gt;
| title     = Conditional Compilation&lt;br /&gt;
| publisher = Microsoft Corporation&lt;br /&gt;
}}&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Code examples:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;javascript&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;script&amp;gt;&lt;br /&gt;
/*@cc_on&lt;br /&gt;
  document.write(&amp;quot;You are using IE4 or higher&amp;quot;);&lt;br /&gt;
@*/&lt;br /&gt;
&amp;lt;/script&amp;gt;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
There were also several predefined variables,&amp;lt;ref&amp;gt;[http://msdn.microsoft.com/en-us/library/7142yyxw(VS.80).aspx Conditional Compilation Variables]&amp;lt;/ref&amp;gt; though these cannot be relied on any longer as Microsoft altered the JScript engine of IE6 with XP SP3 and it now reports as:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;javascript&amp;quot;&amp;gt;@_jscript_version == 5.7&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
As a result, a possible way to detect Internet Explorer version using conditional compilation can be seen below:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;javascript&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;script&amp;gt;&lt;br /&gt;
/*@cc_on&lt;br /&gt;
&lt;br /&gt;
  @if (@_jscript_version == 11)&lt;br /&gt;
    document.write(&amp;quot;You are using IE11 with an older document mode&amp;quot;);&lt;br /&gt;
  @elif (@_jscript_version == 10)&lt;br /&gt;
    document.write(&amp;quot;You are using IE10&amp;quot;);&lt;br /&gt;
  @elif (@_jscript_version == 9)&lt;br /&gt;
    document.write(&amp;quot;You are using IE9&amp;quot;);&lt;br /&gt;
  @elif (@_jscript_version == 5.8)&lt;br /&gt;
    document.write(&amp;quot;You are using IE8&amp;quot;);&lt;br /&gt;
  @elif (@_jscript_version == 5.7 &amp;amp;&amp;amp; window.XMLHttpRequest)&lt;br /&gt;
    document.write(&amp;quot;You are using IE7&amp;quot;);&lt;br /&gt;
  @elif (@_jscript_version == 5.6 || (@_jscript_version == 5.7 &amp;amp;&amp;amp; !window.XMLHttpRequest))&lt;br /&gt;
    document.write(&amp;quot;You are using IE6&amp;quot;);&lt;br /&gt;
  @elif (@_jscript_version == 5.5)&lt;br /&gt;
    document.write(&amp;quot;You are using IE5.5&amp;quot;);&lt;br /&gt;
  @elif (@_jscript_version &amp;lt; 5.5)&lt;br /&gt;
    document.write(&amp;quot;You are using a version older than IE5.5&amp;quot;);&lt;br /&gt;
  @else&lt;br /&gt;
    document.write(&amp;quot;You are using an unknown version of IE&amp;quot;);&lt;br /&gt;
  @end&lt;br /&gt;
 &lt;br /&gt;
@*/&lt;br /&gt;
&amp;lt;/script&amp;gt;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
However, conditional compilation is no longer supported in [[Internet Explorer 11]] Standards mode.&amp;lt;ref&amp;gt;https://msdn.microsoft.com/library/8ka90k2e(v=vs.94).aspx @cc_on Statement (JavaScript)&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==See also==&lt;br /&gt;
*[[CSS filter]]&lt;br /&gt;
*[http://www.moreonfew.com/conditional-comments-in-html/ Conditional Comments in HTML]&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
{{reflist}}&lt;br /&gt;
&lt;br /&gt;
[[Category:HTML]]&lt;br /&gt;
[[Category:Cascading Style Sheets]]&lt;br /&gt;
[[Category:Internet Explorer]]&lt;/div&gt;</summary>
		<author><name>XP1</name></author>	</entry>

	</feed>