How come certain random strings produce colors when entered as background colors in HTML? For example:
chucknorris
starts with c
, and the browser reads it into a hexadecimal value.
Because A, B, C, D, E, and F are characters in hexadecimal.
The browser converts chucknorris
to a hexadecimal value, C00C00000000
.
Then the C00C00000000
hexadecimal value is converted to RGB format (divided by 3):
C00C00000000
⇒R:C00C, G:0000, B:0000
The browser needs only two digits to indicate the colour:
R:C00C, G:0000, B:0000
⇒R:C0, G:00, B:00
⇒C00000
Finally, show bgcolor = C00000
in the web browser.
Here's an example demonstrating it:
chucknorris
c00c00000000
c00000