-1

Using outputField in a html table tag. Can't seem to get the font color to show. Not the planned use of color but need to get this much working.

<table class="htmlDataTable" >     
<td style="background-color: lightgrey; color: yellow">
<apex:outputField value="{!s.Key_Broker_Contact_LU_PS__c}" />
</td>

CSS for htmlDataTable:

table.htmlDataTable {
  border: 0px solid black; 
  text-align: right;
  border-collapse: collapse;
  table-layout: fixed;
  }
table.htmlDataTable td, table.htmlDataTable th {
  border: 1px solid black;
  padding: 5px 5px;
  }

table.htmlDataTable tr:hover {
  background-color: lightgreen;
  }

table.htmlDataTable thead {
    border-bottom: 2px solid black;
  }
table.htmlDataTable thead th {
  font-weight: bold;
  color: blue;
  text-align: center;
  }

1 Answer 1

1

bgcolor is not a standard attribute and may not be supported by all (any?) browsers. Use CSS instead:

<table>
  <tbody>
    <tr>
      <td style="background-color: lightgrey; color: yellow">
        {!s.Key_Broker_Contact_LU_PS__c}
      </td>
    </tr>
  </tbody>
</table>
6
  • Great. I updated the source code in the question. Added the outputField tag to produce the link as well. Thanks.
    – rickmac
    Nov 15, 2017 at 0:06
  • .....hmm when I apply the outputField the color for the font is not enabled as yellow.
    – rickmac
    Nov 15, 2017 at 0:20
  • @rickmac outputField has a style attribute you can use. I believe you can set the color that way.
    – sfdcfox
    Nov 15, 2017 at 0:52
  • Wish it was the case but the outputField style is not enabling the font color either. In fact if I add a color to the CSS for the td this field remains unchanged. <td><apex:outputField style="color: yellow" value="{!s.Key_Broker_Contact_LU_PS__c}" /></td>
    – rickmac
    Nov 15, 2017 at 0:57
  • @rickmac Looks like a bug. You might need to resort to the very manual... <a href="{!URLFOR($Action.Object_Name__c.View, s.Key_Broker_Contact_LU_PS__c, null)}" style="color: yellow">{!s.s.Key_Broker_Contact_LU_PS__r.Name}</a> That's pretty unfortunate. Maybe a new question about why style doesn't work is in order.
    – sfdcfox
    Nov 15, 2017 at 1:22

You must log in to answer this question.

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