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
Anto HotelbedsAnto Hotelbeds 

Applying style to a label, possible?

Hi developers,

 

I think here goes my last question about visualforce :) by now...

 

Y have my lead edit page as follows:

 

<apex:page standardController="Lead" showHeader="true">
    <apex:sectionHeader title="Edit Fiscal Information" subtitle="{!Lead.Company}"/>  
    <apex:form>
        <apex:pageBlock title="Edit Fiscal Information" id="Edit_Fiscal_Information" mode="Edit">
            <apex:pageMessages />
            <apex:pageBlockButtons >
                <apex:commandButton value="Save" action="{!save}"/>
                <apex:commandButton value="Cancel" action="{!cancel}"/>
            </apex:PageBlockButtons>
                <apex:pageBlockSection title="Basic Information - All fields required" columns="2">
                    <apex:inputField value="{!lead.Street_fiscal__c}" label="Street (Fiscal)*"/>
                    <apex:inputField value="{!lead.City_fiscal__c}" label="City (Fiscal) *"/>
                    <apex:inputField value="{!lead.Post_Code_fiscal__c}" label="Post Code (Fiscal) *"/>
                    <apex:inputField value="{!lead.Country_Fiscal__c}" label="Country (Fiscal) *"/>
              </apex:pageblockSection>

 Now, when I request a field, for example "!lead.Street_fiscal__c and I define the label "Street (Fiscal) *", I would like the label to be shown in blue color because this is a special field that is compulsory for a process and I want my users to detect it somehow...

 

I tried using style, but the style is apply to the contect of the Street_fiscal field, not to the label itself.

 

Can I do that somehow?

 

Thanks a lot.

 

Antonio

Best Answer chosen by Admin (Salesforce Developers) 
yvk431yvk431

Replace the line
 <apex:inputField value="{!lead.Post_Code_fiscal__c}" label="Post Code (Fiscal) *"/> with the below block

<apex:pageBlockSectionItem >
              <apex:outputLabel value="Post Code (Fiscal) *" style="color:blue" />
              <apex:inputField value="{!lead.Post_Code_fiscal__c}"/>
              
          </apex:pageBlockSectionItem>

 

 

--yvk

All Answers

yvk431yvk431

Replace the line
 <apex:inputField value="{!lead.Post_Code_fiscal__c}" label="Post Code (Fiscal) *"/> with the below block

<apex:pageBlockSectionItem >
              <apex:outputLabel value="Post Code (Fiscal) *" style="color:blue" />
              <apex:inputField value="{!lead.Post_Code_fiscal__c}"/>
              
          </apex:pageBlockSectionItem>

 

 

--yvk

This was selected as the best answer
Anto HotelbedsAnto Hotelbeds

Thank you very much!!!

prazonprazon

looks nice solution