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
Dileep KumarDileep Kumar 

I want to show color on visualforce page.

Hi all,

I created one object , in this object i created one text field and in this text field i am storing hex code of color. now i want to show this color on vf page.how i will do it.

please help me.

Thanks,

Dileep

Best Answer chosen by Dileep Kumar
Nupoor SharmaNupoor Sharma
Hi Dileep,

The color can be set in a style tag using the {!Custom_Object__c.Field_Name__c} syntax.

For example: If the value in the text field is #000000 [hex code for black] and you want to set the background color based on the value in this text field, the below code can be used.  
 
<apex:page standardController="Custom_Object__c"  showHeader="false" sidebar="false">

<style>
body {
   background-color: {!Custom_Object__c.Field_Name__c};
}
</style>

<body> </body>
   
</apex:page>