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
MellowYellowMellowYellow 

apex:outputText style not able to set font to bold

I am trying to add bold font formatting by using the style attribute.  I am able to set the style to italic, or the color to red, but not the font-weight;

<apex:pageBlockSectionItem >
                <apex:outputText style="font-weight:900;" value="This text should be in BOLD" />
                <apex:inputField value="{!Opportunity.Test_Field__c}"/>
</apex:pageBlockSectionItem>



I would also like to be able to insert a line-feed in the outputText if possible.

 

I  tried adding the escape="true" attribute, but wasn't able to add <B></B>  or <BR> tags that were recognized by the browser as HTML.


Best Answer chosen by Admin (Salesforce Developers) 
aballardaballard
<apex:page >
  <apex:pageblock >
  <apex:pageblocksection >
  <apex:pageblocksectionitem >
  <apex:outputText style="font-weight:800" value="this text should be in bold"/>
  </apex:pageblocksectionitem>
  <apex:pageblocksectionitem >
  <apex:outputText escape="false" value="<b>and so should this</b>"/>
  </apex:pageblocksectionitem>
  <apex:pageblocksectionitem >
  <apex:outputText value="but not this"/>
  </apex:pageblocksectionitem>
  </apex:pageblocksection>
  </apex:pageblock>
</apex:page>

 

All Answers

aballardaballard

Hm, I just tried and both approachs (using the style and using escape=false with embedded markup)  work for me.  There must be something else in your page that is affecting it somehow....

MellowYellowMellowYellow

Thanks for the fast reply.  Can you provide the code which worked?  I'll compare this to mine to see if I have a syntax error or am missing something.

aballardaballard
<apex:page >
  <apex:pageblock >
  <apex:pageblocksection >
  <apex:pageblocksectionitem >
  <apex:outputText style="font-weight:800" value="this text should be in bold"/>
  </apex:pageblocksectionitem>
  <apex:pageblocksectionitem >
  <apex:outputText escape="false" value="<b>and so should this</b>"/>
  </apex:pageblocksectionitem>
  <apex:pageblocksectionitem >
  <apex:outputText value="but not this"/>
  </apex:pageblocksectionitem>
  </apex:pageblocksection>
  </apex:pageblock>
</apex:page>

 

This was selected as the best answer
MellowYellowMellowYellow

It looks like styling on label doesn't work appropriately once there's an inputField or inputText in the same pageBlockSectionItem.  I ended up using <big></big> instead of <b></b> and this worked well enough.

 

Thanks for your help