What has “Walter White” got to do with actual colours and HTML?
Breaking Bad is a bit of a hot topic at the moment (I’m a fan myself) but you’re probably thinking where on earth is he going with this, “Walter White” isn’t a valid colour. Let me explain before you think I’ve gone mad.
The above code snippet will actually colour the text “Walter White”, in a Breaking Bad green, automatically.
Don’t believe me? Here’s a live demo. Apologies for the use of a font tag.
What is going on here?!
It does seem crazy but fortunately there is some science behind it :)
The cooking process
- Replace all invalid hexadecimal characters with “0”
- Divide all hexadecimal characters into 3 even groups (pad if necessary)
- Take the first 2 hexadecimal characters from each group
No? Let’s step through the example.
- “Walter White” becomes “0a00e000000e” when replacing invalid hexadecimal characters with “0”
- “0a00e000000e” is 12 characters long, so dividing into 3 groups gives “0a00 e000 000e”
- Taking the first 2 hexadecimal characters from each group in “0a00 e000 000e” produces “0a e0 00”
“Walter White” = “#0ae000”
I would have expected it to be blue, but I’m guessing the process isn’t 100% pure :)