Font color with coldfusion?


  <CFOUTPUT QUERY="news">
        <B><font size="1" face="Verdana"><span style="text-transform: uppercase">#DateFormat(WhatDate, 'dd.MMMM.yyyy')#</span><BR></B>
        <B><p style="line-height: 100%; word-spacing: 0; margin-top: 0; margin-bottom: 0"><font size="1" face="Verdana" color="red">#WhatName#</font></p></B>
		   <B><p style="line-height: 100%; word-spacing: 0; margin-top: 0; margin-bottom: 0"><font size="1" face="Verdana" color="red">#WhatPost#</font></p></b>
           <p style="line-height: 100%; word-spacing: 0; margin-top: 0; margin-bottom: 0"><font size="1" face="Verdana">#WhatDesc#</font></p>
		   <p align="right">&nbsp;</p>
         <div align="center"><a href="viewall.cfm">View All</a></div>
  </CFOUTPUT>

This is a part of a news script and this is part of the page that displays the news, (based on the tutorial from cfm-resources) and I am messing around with the font, spacing, etc.

First off I know that this is a lot of junk code that isn’t necessary. But my problem is, when I try to add a custom color into the font tags (color=“#800000” is the exact color I need) it comes up with an error from what I believe is the # before the color code because CF uses that for variables. Any ideas?

I think either color=“##800000” or color=“####800000” may work.

I don’t use CF but something similar came up in a previous thread. I think it may be possible to output the # character with a CF char function but I dont know the relevant function.

Something else you may want to do is use a style class and specify the style attributes in a style sheet. You could then just change the style sheet to change the colour without messing with your CF code.

2 things.

  1. works.

  2. You don’t need the # sign anyways. You can simply specify a color in it’s hex value without a preceding #

Chris,

Thanks for the clarification on the number of #'s needed.

As to leaving off the # when specifiying colors, I’m not totally sure that it’s legal html. I guess if it works in browsers it’s not a huge deal but just something to be aware of.

W3C’s html 4.0 spec
6.5 Colors
The attribute value type “color” (%Color; [p.281] ) refers to color definitions as specified in [SRGB] [p.354] . A color value may either be a hexadecimal number (prefixed by a hash mark) or one of the following sixteen color names. The color
names are case-insensitive. [p.49]