Bogus bgcolor value
I incidently entered my own name in the body bgcolor attribute, and it resulted in a specific dark blue shade. It is obviously not a standard color name, also the same does not work if I put it in CSS background-color. <body bgcolor="TiborSanta"> I know we should probably not even use this attribute as it is deprecated in HTML5. But I am curious, how is this color calculated at all? https://code.sololearn.com/Wkp1me8Fqbn0/?ref=app
visph is right but .. here is an interesting (maybe) story 😂.. i had a peek into chromium's source code to actually understand whats going on.. i couldn't post long text on q/a so .. here's it https://code.sololearn.com/Wo3ILnE9mqz6/?ref=app
as very permissive language, html (not css) parse unknown colors as hex values, replacing invalid 'digits' with 0... so 'TiborSanta' result as '00b000a00a', spliting in 3 parts, and getting only first 2 digits of each: "#0000a0" ;)
visph that's what I had initially thought as well, but it doesn't seem to be the case. When replacing the values in the original string with other unknowns the color did change for me. Most commonly to a green and black.
visph might have been a fluke (or I put a character in the wrong place, lol), it's staying the same now.
This is curious. It seems to be only the 1st 7 characters that matter, and of course upper or lower case is irrelevant. You'll get the same result for "tiborsa". Mine "chaotic" gives a pleasing magenta like color. I would be interested to know as well how it achieves these results. I can only assume it's some type of character value overflow.
Thank you guys. This has been fun to read through! The SO article really sheds some light on this mystery, but I award the top answer to Prashanth Kumar who did investigate the browser source code himself to arrive at the same conclusion! Well done :)