When used inside of a <apex:pageBlockSection> component, Visualforce input components and some output components automatically display a form label for the field. For components that map to standard or custom object fields, the displayed label is the object field label by default. To override the default value, and for components that aren’t mapped directly to object fields, you can set the label using the label attribute of the component. For example:
<apex:page standardController="Contact"> <apex:form> <apex:pageBlock title="Quick Edit: {!Contact.Name}"> <apex:pageBlockSection title="Contact Details" columns="1"> <apex:inputField value="{!Contact.Phone}"/> <apex:outputField value="{!Contact.MobilePhone}" label="Mobile #"/> <apex:inputText value="{!Contact.Email}" label="{!Contact.FirstName + '’s Email'}"/> </apex:pageBlockSection> <apex:pageBlockButtons > <apex:commandButton action="{!save}" value="Save"/> </apex:pageBlockButtons> </apex:pageBlock> </apex:form> </apex:page>
The label attribute may be a string, or an expression that evaluates to a string. If you set label to an empty string, the form label for that field will be suppressed.
The label attribute can be set on the following Visualforce components:
When set, the label attribute will be used for component-level error messages, for example, when a field is required or must be unique. Custom labels won't be used in custom error messages, and the default object field label will be used instead. If you set a label attribute to an empty string, the default object field label will be used in all error messages.