<apex: outputField> Component in Visualforce Page
The <apex: outputField> is one of the most used components in Visualforce Page that act as a read-only display of a label and value for a Salesforce object's field. All the attributes associated with the Salesforce field are respected by this component.
We use this component for getting input from the user for a controller method that doesn't correspond to a Salesforce Object's field.
The <apex: outputField> component should always be the child of the <apex: pageBlock> and <apex: pageBlockSectionItem> components.
HTML pass-through attributes are supported by this component by using the "html-" prefix.
The <apex: outputField> component has the following attributes on Visualforce Page:
The dir is a string-type attribute that is used for specifying the direction in which the generated HTML component should be read. RTL and LTR are the two possible values for this attribute.
The id is a string-type attribute, i.e., a unique identifier that allows this component to be referenced by other components on the page.
The label is a string-type attribute that is used for specifying the text value that needs to be used as the component label.
The lang is a string-type attribute that is used for specifying the base language for the generated HTML output.
The rendered is a Boolean-type attribute that is used for specifying whether this component needs to be rendered on the page or not. Boolean-value true is set as a default value for this attribute.
The style is a string type attribute used to specify the inline CSS style that will be applied for displaying the input component.
The styleClass is a string type attribute used to specify the style class that will be applied for displaying the input component.
The title is a string-type attribute used to specify the text that needs to be displayed as a tooltip when the user hovers the mouse pointer over this component.
The value is an Object-type attribute that is used for specifying the expression that references the Salesforce field associated with this output field.
Let's take an example to understand how we can use this component on Visualforce Page: