4 ms·
Why does HTML think “chucknorris” is a color?
- birdyrooster 6y agoFuzzy matching of color names which has existed since forever in browsers, but I have never seen an implementation’a source code. It’s probably some simple distance algorithm packaged into a unit that compares bgcolor color against a preprogrammed list of colors.
- dan-robertson 6y agoThat’s not what it is at all. See the first answer in the OP.
- birdyrooster 6y agoMy guess is as good as poop.
- readingnews 6y agoAll of those stackoverflow comments are wrong. It is because Chuck Norris is mad that you made an error in your HTML code, causing the color to be red, because he is going to kick our asses.
- cratermoon 6y agoAh, tag soup. How much of that stuff is still sloshing around the web?
- bryanrasmussen 6y agoSo now it makes me wonder - how much slower is it to use the keyword red than to use a hex value, and how much slower is it to use chucknorris than red. Is there an unexpected text string (or strings) that will produce a color that takes the largest amount of steps for the browser to produce out of the string, thus, I assume, using more computing power.
- GekkePrutser 6y agoThe answer is unfortunately a bit boring :'( I was hoping for some cool story with some deep easter egg.. But no. <spoiler>It's just that non-existing hex chars are replaced by 0's :P</spoiler>
- kibwen 6y agoNo, the full algorithm is actually fascinating in how utterly absurd it is. I'll use the example from the primary source, https://scrappy-do.blogspot.com/2004/08/little-rant-about-microsoft-internet.html https://scrappy-do.blogspot.com/2004/08/little-rant-about-mi... . 1. Start with some random string: 6db6ec49efd278cd0bc92d1e5e072d68 2. Pad the end of the string with zeroes until the length is a multiple of 3: 6db6ec49efd278cd0bc92d1e5e072d680 3. Split the string into equal thirds: 6db6ec49efd, 278cd0bc92d, 1e5e072d680 4. Counting from the end (?!) of each third, truncate to eight (??) characters: 6ec49efd, cd0bc92d, e072d680 5. Counting from the beginning of each segment, truncate to two characters: 6e, cd, e0 And that's how a string like "6db6ec49efd278cd0bc92d1e5e072d68" turns, unbelievably, into a hex value of "#6ecde0".
- GekkePrutser 6y agoLol I only glanced over the source article, not sure if it mentioned all this. But inded. It is absurd :D Thanks for the explanation, it was really a good laugh! I wonder what they were thinking at netscape.. Why not just ignore invalid values... :/ And of course some words are actually parsed as valid values (like red, blue etc) which makes it even more complex.
- dang 6y agoIf curious see also 2017 https://news.ycombinator.com/item?id=14122612 https://news.ycombinator.com/item?id=14122612 2013 https://news.ycombinator.com/item?id=6662342 https://news.ycombinator.com/item?id=6662342 Of the 26 submissions (https://hn.algolia.com/?query=Why%20does%20HTML%20think%20%E2%80%9Cchucknorris%E2%80%9D%20is%20a%20color%3F&&sort=byDate&dateRange=all&type=story&storyText=none&prefix https://hn.algolia.com/?query=Why%20does%20HTML%20think%20%E...), these are the two with comments that aren't just chuck norris jokes or complaints about how often this has been posted.
- accrual 6y agoWould anyone like to critique my quick Javascript implementation [1] of this answer on the same page [2]? [1] https://repl.it/repls/ImmediateSilentErrors https://repl.it/repls/ImmediateSilentErrors [2] https://stackoverflow.com/a/12940384 https://stackoverflow.com/a/12940384
- m3047 6y agoIf this isn't a quintessential hack, what is?
- nunez 6y agoOkay, this is an amazing use of a bug.
- shiftpgdn 6y agoI find it peculiar that this user "kiyanwang" is submitting 7-8 stories a day, with multiple stories hitting the front page.
- a1369209993 6y agoAlso, their last comment was in 2017. WTF?