I am using an example of custom component from - https://developer.salesforce.com/docs/atlas.en-us.pages.meta/pages/pages_comp_cust_elements_attributes.htm

Here is my custom Component:


    <!-- Attribute Definitions -->
    <apex:attribute name="myValue" description="This is the value for the component."
                    type="String" required="true"/>
    <apex:attribute name="borderColor" description="This is color for the border."
                    type="String" required="true"/>

    <!-- Component Definition -->
    <h1 style="border:{!borderColor};">
        <apex:outputText value="{!myValue}"/> 


My VF page has:

<apex:page >

<c:recorddisplay myValue="My value" borderColor="red"/>


When I check my VF page I do not get the Red border color or any where as "Red" color. I also tried below code in my component, but I do not see any background color in my page. What is wrong with this example? -

<h1 style="bgcolor:{!borderColor};">
        <apex:outputText value="{!myValue}"/> 
  • 1
    For the border property, you would usually specify (dimensions?) e.g. border: 1px solid red .. And background-color over bgcolor... At least Chrome doesn't seem to like bgcolor – Antonio Manente Apr 20 '16 at 19:17
  • That makes sense. The example in salesforce document looks wrong. This code in VF page worked- <c:recorddisplay myValue="My value" borderColor="1px solid red"/> – SfdcBat Apr 20 '16 at 19:21
  • Yeah, unfortunately. Your usage of the attribute component is correct just css issues. – Antonio Manente Apr 20 '16 at 19:25

Documentation is not entirely correct.

the border property should be as follows:

border: width style color

So it would be:

style="border: 1px solid {!borderColor}"

although this would work as well

style="border: solid {!borderColor}"


| improve this answer | |
  • Your right! The document is not entirely correct. – SfdcBat Apr 20 '16 at 19:21

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.