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
rtyanasrtyanas 

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

Hi,

 

Please try to use styleclass attribute of output field.

 

-S

 

 

 

 

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.
rtyanasrtyanas

 

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

 

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

AnushaAnusha
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.
rtyanasrtyanas

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

AnushaAnusha

try this,

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

if not

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

and in <style> tags

.AlignOptFilld span {
text-align:left;
}