You need to sign in to do that
Don't have an account?
Andrea Sloan
VisualForce how to add color to a table row
I have a Visualforce page with a table and would like to add color to my cells and in some cases to my entire row. I don't know what the syntax is to insert the color and what it is I need to insert and where in my table to indicate that I want a particular color either for a cell or for the entire row. Cna someone help me by posting the syntax in the exact format opening and closing statements that I must include for this to go through? Perhaps include a sample color that I could test out.
So your style tag becomes...
style="text-align:center;font-size:14pt;background-color:#f37422;"
Note also - I changed the font-size part of the css to PT, not PX.
All Answers
below is the sample code for your reference.
<table>
<tr>
<td style="font-size:15px;background-color: #f37422;"> <b> <u> <apex:outputLabel value="Sample Data"></apex:outputLabel> </u> </b> </td>
</tr>
</table>
Hope this helps!
Thanks
<TR>
<TD ALIGN = "Center", style="font-size:15px;background-color: #f37422;">
<B>Information and Analysis Reports</B>
</TD>
<TD ALIGN = "Center">
<B> My Follow Up Reports</B>
</TD>
<TD ALIGN = "Center">
<B> Visit Reports</B>
</TD>
</TR>
I understand it's a sample code but in terms of syntax, I'm getting an error and cannot save the page. Would you be able to tweak the below for me so it doesn't tell me I'm missing an "Element type for "TD" and that it must be following by weither ">" or "/>" Thanks for your help!
<TR>
<TD ALIGN = "Center", style="font-size:15px;background-color: #f37422;">
<B>Information and Analysis Reports</B>
</TD>
<TD ALIGN = "Center">
<B> My Follow Up Reports</B>
</TD>
<TD ALIGN = "Center">
<B> Visit Reports</B>
</TD>
</TR>
There is a comma after "center" please remove it and give a try.
<TD ALIGN = "Center" style="font-size:15px;background-color: #f37422;">
<B>Information and Analysis Reports</B>
</TD>
It should work.
Thanks
So your style tag becomes...
style="text-align:center;font-size:14pt;background-color:#f37422;"
Note also - I changed the font-size part of the css to PT, not PX.
Now...what if I also want to tell it to increase the size of my font for antoher section outisde of my table but not make mention of a color? I tried to mimick what you ahd done just with the font size part and of course I get a syntax error. I'm nto a developer and not sure what the sequence has to be to get the code straight!!! here is what I have and you'll see that I've indicated a font size to the first line but I get a syntqax error.
<style="font-size:14pt Hello {! $User.FirstName} </font> ;">
<br/>
<B>Please use the fields below to enter your desired dates for the specified reports.</B>
<TABLE Border= "3" CELLSPACING="1" CELLPADDING="1" >
<br/>
<CAPTION><B> Salesforce Reports </B></CAPTION>
<br/>
<TR style="text-align:center;font-size:14pt;background-color:#FFFF00;">
<TD >
<B>Information and Analysis Reports</B>
</TD>
<TD ALIGN = "Center">
<B> My Follow Up Reports</B>
</TD>
<TD ALIGN = "Center">
<B> Visit Reports</B>
</TD>
</TR>
Everything inside of the Style attribute is CSS. You could (should) put it in a seperate CSS file, stored in static resources, and references from the VF page, but I was just trying to add to what you already had.
So, going back to the TD tag that you had....
<TD ALIGN = "Center", style="font-size:15px;background-color: #f37422;">
<B>Information and Analysis Reports</B>
</TD>
should have become...
<TD style="text-align:center;font-size:14px;background-color:#f37422;">
<B>Information and Analysis Reports</B>
</TD>
Now - getting to your latest version - ...
Take the first line<style="font-size:14pt Hello {! $User.FirstName} </font> ;"> out - there is no visualforce or HTML tag call style. (there is an attribute that goes in most tags called style though - and that's where embedded css goes).
The reason it worked is because of the style attribute in the TR tag.
Hope that helps
Thank you!
thank you!!!!