Find your content:

Search form

You are here

Rendering HTML comments from Visualforce pages

 
Share

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.


Attribution to: Daniel Ballinger

Possible Suggestion/Solution #1

This is how we have accomplished this in the past:

<apex:outputText value="<" escape="false" />!-- COMMENT HERE --<apex:outputText value=">" escape="false" />

It's not pretty, by any means, but in our case it was necessary (for compatibility with some JavaScript code). If you absolutely need comments to render in the HTML, then it's at least a working solution.


Attribution to: Matt

Possible Suggestion/Solution #2

Daniel are you referring to comments inside of VF tags?

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


Attribution to: jordan.baucke

Possible Suggestion/Solution #3

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.


Attribution to: Peter Knolle
This content is remixed from stackoverflow or stackexchange. Please visit https://salesforce.stackexchange.com/questions/951

My Block Status

My Block Content