What Colour is Chucknorris?
In CSS, you are giving colors in RGB (Red, Green, Blue) format or hexadecimal format . But what if you came to know that HTML accepts any random string of words as colors?
Hexadecimal color code
A string is a valid simple color if it is exactly seven characters long, and the first character is a U+0023 NUMBER SIGN character (#), and the remaining six characters are all ASCII hex digits , with the first two digits representing the red component, the middle two digits representing the green component, and the last two digits representing the blue component, in hexadecimal .
If you are putting any word at bgcolor that contains a few hexadecimal character then that character will show you some unexpected color that you never imagine.
For example, if you write the following HTML:
You would see the body background painted a nice red.
The logical explanation behind this - during Netscape days, incorrect digits in a color code were considered as 0.
So if you apply the same rule to chucknorris
- Replace all non-hex characters with 0 - you get c00c0000000
- Pad out the characters so the total numbers are divisible by 3 - c00c 0000 0000
- Split into 3 groups for RGB - c00c, 0000, 0000
- Truncate the digits from the right to 2 characters in each color group - c0, 00, 00 (RGB).
This gives you the hex color #C00000 which is a shade of red.
Supported Browsers: The browsers supported by this procedure are listed below:
NEXT.....Difference Between Color and Colour