Take the 2-minute tour ×
Salesforce Stack Exchange is a question and answer site for Salesforce administrators, implementation experts, developers and anybody in-between. It's 100% free, no registration required.

It appears any HTML comments in a Visualforce page are stripped out before the content reaches the users browser.

Is there a way to render comments?

There are some cases where the comments are useful, such as in debugging and CSS conditional comments.

share|improve this question
add comment

2 Answers

up vote 4 down vote accepted

Visualforce definitely strips out the HTML comments and does not render them in the browser as HTML comments. I have observed it, but I don't ever remember reading it in any documentation. Here's the idea to stop that: http://success.salesforce.com/ideaView?id=08730000000iEyFAAU along with a workaround if you really need it rendered.

share|improve this answer
    
I see in the idea there is mention that "support for conditional comments is going to be provided" in Winter 13. I couldn't find any reference to this after a quick search. –  Daniel Ballinger Aug 28 '12 at 23:35
2  
@DanielBallinger - na14.salesforce.com/help/doc/en/… (page 180): "Prior to Winter ’13, HTML and XML comments were allowed in Visualforce pages but were automatically removed during page rendering. This included Internet Explorer-specific “conditional comments” that are often used to address browser compatibility issues. In Winter ’13, these comments are recognized by Visualforce and passed through to the browser." [It is just the conditional comments that will be recognized.] –  Peter Knolle Aug 28 '12 at 23:46
    
Looks like I'll need to update the Visualforce pages to the 26.0 API version to get this. Thanks. –  Daniel Ballinger Aug 28 '12 at 23:53
add comment

Daniel are you referring to comments inside of VF tags?

I have used standard <!-- comment --> in VF pages repeatedly with no problems.

share|improve this answer
    
I've put a basic plain text comment immediately under the opening <apex:Page> tag. The Visualforce page saves fine, but I can't see the comment in the resulting HTML. There are other comments, such as <!-- Main Body Starts Here --> –  Daniel Ballinger Aug 28 '12 at 21:52
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.