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

Displaying Text Unformatted


I have a VF page that displays data from a database with a field Long Text Area.  The data in the field has formatting that I would like to preserve mostly new lines.   I tried to use <pre> but, the text will go off the side of the page almost like the new lines are removed? 


Is there a way to display this text as entered into the DB field (Long Text Area)? I need to display the data as it is entered into the field with new lines and space.


If I change the field type to Rich Text Area will that help?  I have other fields that are Rich Text Area and I seem to get <br> that do not break and only display as <br> is there a way to make the <br> actually break?



Cory CowgillCory Cowgill

Have you tried <apex:outputField value="Object.Field__c/>.


You will have more success in cleanly formatting your data if you use <apex:outputField> <apex:inputField> for your data if possible.


That is not always the case, but if you can I would suggest using those tags.


<apex:outputField value="Object.Field__c/> is giving me the same results.  I am attempting to preserve the format in the field with are mostly new lines.  Are new lines removed before displaying?  If so how do I preserve newlines coming from a DB field?


Display DB text as is (with new lines) use HTML tag <pre>