HTML Comments and IE Conditional Comments
Visualforce doesn’t evaluate anything enclosed within standard HTML comments (<!-- -->), whether the comments are single line or multiline. For non-Internet Explorer comments, the Visualforce compiler replaces the contents of the HTML comment with asterisks. This replacement makes HTML comments unsuitable for commenting out JavaScript code in older browsers.
Internet Explorer conditional comments are most commonly used to address browser compatibility issues, generally with older versions of IE. Although conditional comments work wherever they’re used on the page, they’re frequently placed inside the page’s <head> tags, where they can be used to include version-specific stylesheets or JavaScript compatibility “shims.”
<apex:page docType="html-5.0" showHeader="false" standardStylesheets="false">
<head>
<!-- Base styles -->
<apex:stylesheet value="{!URLFOR($Resource.BrowserCompatibility, 'css/style.css')}"/>
<!--[if lt IE 7]>
<script type="text/javascript"
src="{!URLFOR($Resource.BrowserCompatibility, 'js/obsolete-ie-shim.js')}>
</script>
<link rel="stylesheet" type="text/css"
href="{!URLFOR($Resource.BrowserCompatibility, 'css/ie-old-styles.css')}" />
<![endif]-->
<!--[if IE 7]>
<link rel="stylesheet" type="text/css"
href="{!URLFOR($Resource.BrowserCompatibility, 'css/ie7-styles.css')}" />
<![endif]-->
</head>
<body>
<h1>Browser Compatibility</h1>
<p>It's not just a job. It's an adventure.</p>
</body>
</apex:page>
- Global variables, such as $Resource and $User
- The URLFOR() function
See Microsoft’s documentation for Internet Explorer conditional comments for further details of how to use them.