function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Greg LovelidgeGreg Lovelidge 

Conditional Comments in Visualforce

I've got a couple different stylesheets to deliver to different versions of internet explorer but this is proving difficult with Visualforce.  I'm sure it's possible with some creative solution, I just can't seem to find one.


Ideally, I would use conditional comments as I would in any html page:


<!--[if lte IE 8]>
<apex:stylesheet value="{!URLFOR($Resource.assets, '/assets/css/lteie8.css')}"/>

<!--[if IE 6]>
<apex:stylesheet value="{!URLFOR($Resource.assets, '/assets/css/ie6.css')}"/>

 and the VF page would generate the urls for me despite the comments and it would ouput something like this:


<!--[if lte IE 8]>
<link href="/resource/1295990700000/assets/assets/css/lseie8.css" rel="stylesheet" type="text/css" />

<!--[if IE 6]>
<link href="/resource/1295990700000/assets/assets/css/ie6.css" rel="stylesheet" type="text/css" />


Any ideas how I can output the correct code?  I figure Salesforce would have thought about this if they're serious about Sites.  It's a very common practice.


Thanks in advance,






to develop cross-platform compatible pages please refer to this page from the Visualforce developer guide:



I found a proper workaround:


Add the following two methods to your controller or to an extensions:


public String getLt(){
	return '<';
public String getGt(){
	return '>';

 Then use outputText to output the comments like this


<apex:outputText escape="false" value="{!lt}!--[if lt IE 10]{!gt}"/>
<script type="text/javascript" src="{!URLFOR($Resource.XXXX, 'yourfile.js')}"></script>
<apex:outputText escape="false" value="{!lt}![endif]--{!gt}"/>