Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Hex color code multiple #

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

like image 504
RobinvdA Avatar asked Mar 24 '14 15:03

RobinvdA


1 Answers

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

like image 172
SW4 Avatar answered Sep 29 '22 04:09

SW4