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
wt35wt35 

Styleclass attribute not working

Hi all,

 

I am trying to use the styleClass attribute to apply a specific style but it doesn't work.

When I apply the same style inline in the tag it works.

 

Thanks for explaining me what can be wrong in my code:

 

<apex:page >

    <style type="text/css"> 
      .myClass {
          color:white;
          background-color:#00CC00;
       }
    </style>
    

<apex:outputText styleClass="myClass"> This should be white text with green background 
</apex:outputText>

</apex:page>

 

Best Answer chosen by Admin (Salesforce Developers) 
hitesh90hitesh90

Hi,

 

You have to modify your code as below. give text in value attribute of <apex:outputText>.

 

Visualforce Page:

<apex:page >
    <style type="text/css"> 
      .myClass {
          color:white;
          background-color:#00CC00;
       }
    </style>
<apex:outputText styleClass="myClass" value="This should be white text with green background">
</apex:outputText>
</apex:page>

 

 

 

Important :
Hit Kudos if this provides you with useful information and if this is what you where looking for then please mark it as a solution for other benefits.

Thank You,
Hitesh Patel
SFDC Certified Developer & Administrator & Advanced Administrator & Sales cloud consultant
My Blog:- http://mrjavascript.blogspot.in/

All Answers

hitesh90hitesh90

Hi,

 

You have to modify your code as below. give text in value attribute of <apex:outputText>.

 

Visualforce Page:

<apex:page >
    <style type="text/css"> 
      .myClass {
          color:white;
          background-color:#00CC00;
       }
    </style>
<apex:outputText styleClass="myClass" value="This should be white text with green background">
</apex:outputText>
</apex:page>

 

 

 

Important :
Hit Kudos if this provides you with useful information and if this is what you where looking for then please mark it as a solution for other benefits.

Thank You,
Hitesh Patel
SFDC Certified Developer & Administrator & Advanced Administrator & Sales cloud consultant
My Blog:- http://mrjavascript.blogspot.in/

This was selected as the best answer
wt35wt35

Thanks Hitesh, that works.

 

I am now facing the same with <apex:commandButton>, any hint?

 

(I only managed so far  to modify the background colour of the button inline)

wt35wt35

I will log a new post for this new issue