
Have you ever tried to set the background color in HTML using different lines? For example, the string
<body bgcolor="chucknorris"> test </body>
will make the background of the document blood red in all browsers and on all platforms (
jsfiddle ).
')
By the way, if the word
chucknorri
also leads to red, then
chucknorr
gives yellow!
It became interesting, why is this happening? Welcome under cat.
It turns out this way since the popularity of Netscape:
Skip digits are recognized as 0 [...]. Incorrect characters are recognized as 0. So, for example, the values # F0F0F0, F0F0F0, F0F0F, #FxFxFx and FxFxFx are the same.
Detailed analysis of the parsing algorithm is given
here . If we apply these rules, we get the following:
- Replace all irregular hex characters with 0s , chucknorris turns into c00c0000000
- “We achieve” the number of zeros to the number of characters divided by 3 (11 -> 12), we get
c00c 0000 0000 - We divide it into three groups, each of which is responsible for one RGB component:
RGB (c00c, 0000, 0000) - We cut each of the arguments on the right, leaving 2 characters, and we get our result
RGB (c0, 00, 00) = # C00000 or RGB (192, 0, 0) .
So we get the following (
jsfiddle ):

By the way, it seems that the CSS specification was still changed, so that incorrect color names are simply ignored:
<p><font color='chucknorris'></font></p> <p><font color='#cc0000'> </font></p> <p><span style="color: chucknorris">!</span></p>
PS
GangnamStyle
, of course, also works.
Based on Stackoverflow and Sam's Place .