I have a Visualforce page created on a custom object. This page is related to a list button as"edit all". When user clicks on this button for editing the VF page, it should show the editing field label names in red color. Any suggestion plz.

  • 1
    Have you tried anything? Can you share some code you've started to do to help us know what specific problem you need to have solved?
    – pchittum
    Commented Jan 4, 2015 at 1:55
  • @Peter@Jenny B:Thanks for you reply.But im using the <apex:column>tag with field names.
    – nikkey
    Commented Jan 5, 2015 at 9:58
  • @nikkey updated my answer with one way you could do it using facets and a similar approach to label.
    – Jenny B
    Commented Jan 5, 2015 at 16:15
  • @Jenney :using facets it didnot work on my sceanrio
    – nikkey
    Commented Jan 6, 2015 at 10:59
  • @nikkey, another example added for columns in EDIT2
    – Jenny B
    Commented Jan 6, 2015 at 15:22

1 Answer 1


There are several different ways you can do this, take a look at the help docs here.

For HTML tags , you can define inline CSS code just like in a regular HTML page:

    <style type="text/css">
        p { font-weight: bold; }

    <p>This is some strong text!</p>

The above example should work if you wanted to change all of your labels to red, something like this:

<style type="text/css">
    label { color: red; }

The following example shows how to reference a stylesheet that is defined as a static resource. First, create a stylesheet like the one below and upload it as a static resource named customCSS:

h1 { color: #f00; }
p { background-color: #eec; }
newLink { color: #f60; font-weight: bold; }

Next, create a page that refers to this static resource:

    <apex:page showHeader="false">
        <apex:stylesheet value="{!$Resource.customCSS}" />
        <h1>Testing Custom Stylesheets</h1>
        <p>This text could go on forever...<br/><br/>
           But it won't!</p>

        <apex:outputLink value="http://www.salesforce.com" styleClass="newLink">
            Click here to switch to www.salesforce.com


To shrink the size of your page, you can prevent the standard Salesforce stylesheets from loading by setting the standardStylesheets attribute on the component to false:

    <apex:page standardStylesheets="false">
        <!-- page content here -->

Note that if you don’t load these style sheets, components that require Salesforce CSS might not display correctly, and their styling may change between releases.

All Visualforce components that produce HTML have pass-through style and styleClass attributes. They allow you to use your own styles and style classes to control the look and feel of any HTML tag. For example, the following code sets the class of the and applies a style:

            <style type="text/css">
                .italicText { font-style: italic; }
            <apex:outputText styleClass="italicText" value="This is kind of fancy."/>

The above here would work if you were using the <apex:outputLabel> tag and could use the styleClass="redText", something like:

    <style type="text/css">
        .redText { color: red; }

EDIT2: Similar to the above example for columns you could also use headerClass to modify the style:

    .headerRow .tableTitle {
        color: red !important; 
<apex:column value="{!acct.Name}" headerClass="tableTitle"/>

Another way that I've seen it done is to create the style and just put the tags in the labels themselves, something like:

<style type="text/css">
    redText { color: red; }
<apex:inputField value="{!Account.Name}" label="<redText>Acct Name</redText>"/>

EDIT: This also works with headers in combination with facets like this:

<apex:facet name="header"><redText>Acct Name</redText></apex:facet>

If you want to apply a style using a DOM ID, you must use CSS attribute selectors for the style definition. Attribute selectors rely on the definition of an attribute, rather than an HTML tag, to apply a CSS style. You can set the id value on any Visualforce component; however, that id is sometimes preprended with the id of parent components. For instance, the id of the following code is j_id0:myId:

        <apex:outputText id="myId" value="This is less fancy."/>

Your CSS should take this into consideration by using an attribute selector:

        <style type="text/css">
            [id*=myId] { font-weight: bold; }
        <apex:outputText id="myId" value="This is way fancy !"/>

If you intend to use images in your stylesheet, zip the images with the CSS file and upload it as a single static resource. For example, if your CSS file has a line like the following:

body { background-image: url("images/dots.gif") }

Add the entire images directory and the parent CSS file into a single zip file. For example, if the zip file resource name is myStyles, refer to it like this:

<apex:stylesheet value="{!URLFOR($Resource.myStyles, 'styles.css')}"/>


If a stylesheet has an empty string in a url value, you won’t be able to render that page as a PDF. For example, the style rule body { background-image: url(""); } will prevent any page that includes it from being rendered as a PDF.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .