[SalesForce] How to add field help text in visualforce page

I want to refer standard help text style in visualforce page, how to realize this?

Best Answer

Easier than using CSS, you can do it with Visualforce tags

<apex:pageBlockSectionItem helpText="{!$ObjectType.YOUR_OBJECT.fields.YOUR_FIELD.InlineHelpText}">
    <apex:outputField value="{!REF_TO_OBJ_FROM_CONTROLLER.YOUR_FIELD}"/>
</apex:pageBlockSectionItem>

For example, if you have the following controller :

public class MyController{
    public Account myAccount{get;set;}

     public MyController(ApexPages.StandardController stdController){
        myAccount = stdController.getRecord();
     }
}

And you just want to display account name with the help text, add this code to your VF page

<apex:pageBlockSectionItem helpText="{!$ObjectType.Account.fields.Name.InlineHelpText}">
        <apex:outputField value="{!myAccount.Name}"/>
</apex:pageBlockSectionItem>
Related Topic