HTML: font color=”red” becomes green
jsfiddle.net
jsfiddle.net
= ”red”
= 0red0 (" is not ascii so make 0)
= 00ed0 (r is not hex so make 0)
= 00ed00 (pad)Edit: Heh
= ”#FF0000”
= 0#FF00000 (rule 10)
= 00FF00000 (rule 10)
= 00F F00 000 (rule 12)
= 00 F0 00 (rule 15)
= #00F000 (rule 16)
edit: fixed, was previously erroneously applying rule 14 which gave a result of #0FF000= "blue" = 0blue0 = 0b00e0
it's ”blue” that is interesting.
This is because the source uses curly quotes, which are not recognized as a parameter bracketing, and so the curly quotes are trying to be interpreted as part of the value.
Change the quotes to actual quotes and it starts working as expected.
• Ok, that is in fact green.
• I wonder if this is related to the colour name parsing weirdness that was on HN a couple of weeks ago?
• Heeeey, those aren't ASCII quotes!
I've had bugs in websites where menus would be completely messed up because they didn't fit in their given space, just because the font of choice was not available on Linux and it fell back on something slightly larger.
Edit: Though in the HN title it is much clearer than in the jsfiddle, for me anyway. Might that be it?
My font shows it as a missing character box.
I'm guessing that it just breaks the 'red' into a value which is interpreted as whatever the hex is. (See the chuck norris links posted in this thread).
Wow. I haven't seen a <font> tag in years
You should check out the source code for HN more often. :) <blink>But pg made it!</blink>Exactly my first thought. This is one of the main reasons I frequent this site - I have tons of random tidbits like this cached in my head, so around half of the times someone introduces a problem to me, I am known to reply: "you know, X months back there was a post on Hacker News...".
Basically, the browser thinks it's looking at a malformed hex number and strips the invalid chars, in this case turning “red” into 00ED0. This is padded with 0s until it's divisible by 3, giving 00ED00.
[0]http://stackoverflow.com/questions/8318911/why-does-html-thi...
2) <foo bar=baz> will usually be interpreted as a value by browsers, even though it's illegal, because everything on the web is wrong
3) The browser sees curly quotes as part of baz
4) For lord only knows what reason, the most basic interpretation of that curly quote appears to be the color green. That'll be somewhere in the CSS spec. I don't care to look it up.
If you change those to straight quotes, suddenly it'll start working. Notice that JSFiddle also highlights the source differently.
http://jsfiddle.net/WGSNX/1876/
By the way, the "font" tag is over, and setting color that way is also over. <span style="color:red">Like this please</span> if you need to do inline styling.
Several blogs engines seem to like automatically converting normal quotes to curly quotes in an attempt to prettify their text rendering. I remember copy and pasting code snippets in the and having to fix this.
[1]http://stackoverflow.com/questions/8318911/why-does-html-thi...
<font color=”chucknorris”>Red, anyone?</font>
[1] https://news.ycombinator.com/item?id=6662342
[2] https://stackoverflow.com/questions/8318911/why-does-html-th...
I remember that HTML had named colors, like "goldenrod" and "peachpuff". Or was that just css?
red => #red => #0ed => #ed => #ed0 => #eedd00
Could be this?
EDIT: That was wrong:
red => #red => #0ed => #00ed00 seems the correct one.
<font color=”green”>Green, anyone?</font><br>
<font color=”blue”>Blue, anyone?</font><br>
<font color=”red”>Red, anyone?</font><br>and
color="red"
Note the difference between ” and "
"red" is in fact red.
”abc” is still green!
isn't this just a case of using something incorrectly and getting an undefined result? just leaves me wondering why errors like this aren't reported or at least warned about by the browser.
if this was the compiler for any language that wasn't HTML (cringes at the thought of that being a language and not just a data format) it would never ship in such a poor state...