7

While editing some old ColdFusion code I found a <td> which has a bgcolor property. The value of it was ##89969E. I copied the code to a HTML file and found out the color was different in ColdFusion.

Now, i noticed the double #, so i removed one and the color was the same. Why does the color change when adding/removing a #?

jsFiddle

RobinvdA
  • 1,313
  • 2
  • 13
  • 28
  • 3
    The double ## is how to escape any # that you need to send to the browser, inside of `` tags. Otherwise CF server interprets the # as the beginning of a CF variable, and probably error at undefined variable '89969E'. – duncan Mar 24 '14 at 15:39

1 Answers1

5

As a basic premise, additional hashes are interpreted as a missing/erroneous value and so replaced with a zero, so ##89969E becomes #0089969E. Note that HEX codes can be as long as 8 digits following a hash (if aRGB), where the last two refer to transparency

Missing digits are treated as 0[...]. An incorrect digit is simply interpreted as 0. For example the values #F0F0F0, F0F0F0, F0F0F, #FxFxFx and FxFxFx are all the same.

When color strings longer than 8 characters or shorter than 4 characters are used, things start to get strange.

However there are a lot of nuances - you can find out more about this here, and for some fairly entertaining results this creates, have a little read here

Community
  • 1
  • 1
SW4
  • 69,876
  • 20
  • 132
  • 137