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


Why does HTML think chucknorris is a color?

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 .

Hexadecimal Conversion

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:

<html> <body bgcolor="chucknorris"></body> </html>

You would see the body background painted a nice red.


The Chuck Norris Color code

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

  1. Replace all non-hex characters with 0 - you get c00c0000000
  2. Pad out the characters so the total numbers are divisible by 3 - c00c 0000 0000
  3. Split into 3 groups for RGB - c00c, 0000, 0000
  4. 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:


chucknorris supporting browsers



NEXT.....Difference Between Color and Colour