8 ms·
HTML: font color=”red” becomes green
- cientifico 13y agoI don't know why is considering that as a RGB notation instead of the color red, but following this progression seems correct: http://jsfiddle.net/7ACky/2/ http://jsfiddle.net/7ACky/2/ red => #red => #0ed => #ed => #ed0 => #eedd00 Could be this? EDIT: That was wrong: red => #red => #0ed => #00ed00 seems the correct one.
- rb2e 13y agoThats odd but I see it all light green on Chrome, Windows 7. http://i.imgur.com/0mRarjC.png http://i.imgur.com/0mRarjC.png
- shdon 13y agoCute. Use normal quotes ;) HTML colour parsing for invalidly specified colours is odd to say the least.
- lucb1e 13y agoSomeone sent a friend of mine this code: ”Why is this not working?!” It was puzzling for a few minutes :)
- Piskvorrr 13y agoWith that font, it's obvious straight away; wouldn't want to debug this for sure.
- andybak 13y agoHard to spot. I can imagine this happening in the real world. 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.
- mattmanser 13y agoAnd Word.
- supermatt 13y agohttp://www.whatwg.org/specs/web-apps/current-work/multipage/common-microsyntaxes.html#rules-for-parsing-a-legacy-color-value http://www.whatwg.org/specs/web-apps/current-work/multipage/... = ”red” = 0red0 (" is not ascii so make 0) = 00ed0 (r is not hex so make 0) = 00ed00 (pad)
- meerita 13y agosuperb
- lucb1e 13y agoThat makes a great lot of sense, well explained! This should be on top of the comments. Edit: Heh
- Svip 13y agoThis neatly explains why `red` also becomes green.
- polymatter 13y agoAnd also explains why, "blue" is actually blue = "blue" = 0blue0 = 0b00e0
- hmottestad 13y ago"blue" is actually supposed to be blue. Like "yellow" or "green" or "black" it's ”blue” that is interesting.
- niqmk 13y agoNot only "red" it's #ff0000 or #ffff00
- nmc 13y agoA recent HN discussion [1] on a less recent Stackoverflow thread [2] has some more examples, and some good answers. [1] https://news.ycombinator.com/item?id=6662342 https://news.ycombinator.com/item?id=6662342 [2] https://stackoverflow.com/questions/8318911/why-does-html-think-chucknorris-is-a-color https://stackoverflow.com/questions/8318911/why-does-html-th...
- quarterto 13y agoWow. I haven't seen a <font> tag in years. My thought processes loading this: • 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!
- Svip 13y agoMaybe something is wrong with me, but the first thing I noticed was the quotes. In fact, from the title posted on HN.
- tjosten 13y agoSame here.
- sacado2 13y agoMe too. I thought "can't be that, too easy", so I looked for another mistake.
- lucb1e 13y agoI'd like to ask everyone saying "I saw the quotes right away," what OS do you use? Perhaps your OS uses a different font. 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?
- tylerlh 13y agoI'm using Chrome on OSX and the color value was highlighted red in the source, so I immediately looked at that.
- jaredmcateer 13y agoChrome on Windows and Linux, on HN and jsFiddle, the quotes were very obvious to me.
- dan1234 13y agoThere was a big Stack Overflow post on HTML color rendering[0]. 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-think-chucknorris-is-a-color http://stackoverflow.com/questions/8318911/why-does-html-thi...
- captainmuon 13y agoWot? Didn't that use to work? I remember that HTML had named colors, like "goldenrod" and "peachpuff". Or was that just css?
- captainmuon 13y agoHah, got it. The snipped used curly quotes instead of regular ones :-) http://jsfiddle.net/WGSNX/122/ http://jsfiddle.net/WGSNX/122/
- izietto 13y agoLOL I love it. I would never find out the trick without read the comments here.
- vs4vijay 13y agoShould put style="color: red"
- vincentmilliken 13y ago"chucknorris" is also a colour, it will turn the text redish.[1] [1]http://stackoverflow.com/questions/8318911/why-does-html-think-chucknorris-is-a-color http://stackoverflow.com/questions/8318911/why-does-html-thi...
- biot 13y agoI fixed it for you: http://jsfiddle.net/WGSNX/170/ http://jsfiddle.net/WGSNX/170/
- forlorn 13y agoI changed ” to " and the text is red.
- jheriko 13y agohmm... if i set colour to #000000 and use the correct quotes it changes the background and not the foreground. 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...
- ma2xd 13y agoThe <font> tag is not supported in HTML5. Use CSS instead. Source: http://www.w3schools.com/tags/tag_font.asp http://www.w3schools.com/tags/tag_font.asp
- deleted 13y ago[deleted]
- justbaker 13y agoNot the point...
- cinitriqs 13y agoLol, truism, yet, for older frameworks, layers of code that are always "in front" of the css (for whatever damned reason) this might still become an issue in some form or another. That said, it should obviously show through when the "test-phase" is there to verify every line of code. nice find though, nice find.
- Ryoku 13y agoThis is not related to the topic in question.
- ramigb 13y agoChanging the curly quotes to normal double quotes will make it behave normally.
- deleted 13y ago[deleted]
- timinman 13y agoThis is exactly the kind of post we need more of on HN!
- hmottestad 13y agocolor=”red” and color="red" Note the difference between ” and " "red" is in fact red. ”abc” is still green!
- hernan604 13y agotry font color="crap"
- ariejan 13y agoYou're not using "-quotes, but the fancy styled ones.
- deleted 13y ago[deleted]
- munimkazia 13y agoCSS has spoiled us! It took me a while to realize that the font tag's color attribute only accepts hex color codes.
- bmaeser 13y agoso is "asdf" http://asdf.com/asdfgreen.html http://asdf.com/asdfgreen.html
- anupshinde 13y agoChange to quote to "
- hugofonseca 13y agowrong quotes used ” as opposed to "
- frogpelt 13y ago<font color=”green”>Green, anyone?</font><br> <font color=”blue”>Blue, anyone?</font><br> <font color=”red”>Red, anyone?</font><br>
- moozeek 13y ago”chucknorris” will make it red: <font color=”chucknorris”>Red, anyone?</font>
- BostX 13y agoMean!
- hawkw 13y agoOops.
- paulmcpazzi 13y agoEverybody knows that you have to use `chucknorris` if you really need the red color: http://jsfiddle.net/WGSNX/1379/ http://jsfiddle.net/WGSNX/1379/
- nicholaides 13y agoWeird. On mine, it's blue: http://jsfiddle.net/Ta7xp/ http://jsfiddle.net/Ta7xp/
- ushi 13y agoObviously, it was implemented by a developer suffering from red–green color blindness.
- calvintennant 13y agoWhat the fuck kind of quotes are those?
- rbosinger 13y agoNow I'm positive that we're all wasting our lives.
- readnews 13y agoit should be "red" not ”red”.
- JohnHaugeland 13y ago1) Curly quotes are not a valid surrounding for values. 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/ 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.
- russellsprouts 13y agoI believe that HTML 5 allows for unquoted values. As long as the attribute doors not contain HTML special characters or spaces, it's legal to omit them.
- reissbaker 13y agoCorrect. The HTML5 spec includes "unquoted attribute values," which have some special restrictions (no spaces, can't be the empty string, can't use HTML characters like >, <, or =, and — duh — no quotes). http://www.w3.org/TR/html-markup/syntax.html#attr-value-unquoted http://www.w3.org/TR/html-markup/syntax.html#attr-value-unqu...
- JohnHaugeland 13y agoYes, and that's the mechanism by which HTML gets confused and thinks that the curly quotes, which are not recognized as value bracketting, are part of the value.
- anon_java_hater 13y agoanother day, another XSS exploit vector
- xer0x 13y agohaha! Awesome thanks for this
- bbunix 13y agoI just can't believe this made it to the front page of hacker news... oh well, Black Friday.
- Aloha 13y agoI swear something like this was posted about a month ago.
- mrpickles 13y agoI think were all just color blind.
- augustolg 13y agoThis works: (font color='red'>Red, anyone?</font)
- deleted 13y ago[deleted]
- nbrogi 13y agoOP, you didn't realize you had the wrong quotes?
- deleted 13y ago[deleted]
- codebrain 13y agohttp://jsfiddle.net/WGSNX/2513/ http://jsfiddle.net/WGSNX/2513/
- krob 13y agothe reason it didn't work is you were not using ASCI values. HTML even though it supports multi-byte strings, the constructs which power the html spec do not support multi-byte strings. Also smart-quotes are note part of that spec and will be interpreted incorrectly. replace smart-quotes with normal quotes will make it work correctly.
- harishanchu 13y agoI think it is a bug with jsfiddle. It render you code: <font color=”red”>Red, anyone?</font> like this: <font color="”red”">Red, anyone?</font> And if you try like: <font color=red>Red, anyone?</font> it works.