You can add \n
for HTML NewLine character in Apex String, and you can replace each \n
by <br/>
in Visualforce page using JSENCODE
function.
SUBSTITUTE(JSENCODE(Variable), '\\n', '<br/>')
Apex Controller:
public class SFController{ public String myVariable {get;set;} public SFController(){ myVariable = 'Sales Cloud' + '\n' + 'Service Cloud' + '\n' + 'Community Cloud'; } }
Visualforce Page:
<apex:page controller="SFController"> <apex:outputLabel value="{!SUBSTITUTE(JSENCODE(myVariable), '\\n', '<br/>')}" escape="false"/ > </apex:page>