Array
University of Oregon

Why does CSS think Chuck Norris is a color?

Why does CSS think Chuck Norris is a color?


Because “Chuck Norris” can be converted to a hexadecimal number.

Here are the CSS rules to parse random strings as hex triples:

  1. Make the string a length that is a multiple of 3 by adding 0s: chucknorris0
  2. Separate the string into 3 equal length strings: chuc knor ris0
  3. Truncate each string to 2 characters: ch kn ri
  4. Keep the valid Hex digits, and add 0’s where necessary: C0 00 00
/* What color are these? What color is your name in Hex? */
p#one {background-color: "ChuckNorris";}
p#two {background-color: "LadyGaGa";}
p#three {background-color: "GangnamStyle";}
Skip to toolbar