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

Force Apex:Component to render a div ?

I have wrapped some html tags in an <apex:component> but upon rendering it generates a span in which all contents are placed.

This sometimes messes up with styles.


Is there a property or method by which apex component can be forced to render a div or no wrapper at all ?

outputPanel offers "A set of content that is grouped together, rendered with an HTML span tag, div tag, or neither. Use an outputPanel to group components together for AJAX refreshes."

Hi Shikibu,

Thanks for your reply.

But i really need the code to be inside a component because i would be calling from multiple pages and would like to avoid copy pasting of code.



I also had this problem once before. I did a simple trick and solved the problem. I don't know whether it would be helpful for you. See my answere in this thread. 


Seems interesting..

But i wish i had a property on component to control its rendering container.


As of API 25, component has a "layout" attribute. You can specify "Block" to make it wrap with a div, "Inline" (which is default) for a span, or "None" for no wrapping.