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

Cannot format apex:outputField

The text does not align left it is always aligned center why?

<apex:outputField value="{!doc__c}" style="text-align:left" />

I have tried using a span without luck, any other ideas?

Sonu Sharma.ax1610Sonu Sharma.ax1610



Please try to use styleclass attribute of output field.







Rahul SharmaRahul Sharma
if you are using outputField, then it automatically includes label and value.
Now if you want align it to the left or right, you should use float property of css.

Note : text-align - works for input field whereas; float - works for output fields.


I tried to use the float property without success the output is centered not left justified.


            <p  >
                <apex:outputField value="{!description__c}" style="float:left" />

If you're writting that outputField in a PageBlock then you cannot control the alignment of text.
for this you need to override the SFDC CSS.

Yes the outputField is in a pageBlock, is there an example of overriding the SFDC CSS?


try this,

<apex:outputPanel layout="block" style="text-align:left" >
<apex:outputField value="{!description__c}" />

if not

<apex:outputPanel layout="block" styleClass="AlignOptFilld" >
<apex:outputField value="{!description__c}" />

and in <style> tags

.AlignOptFilld span {