views:

586

answers:

4
+4  Q: 

Euro sign in HTML

Hello!

The euro (€) is the official currency in 22 European states.

In HTML there are different possibilities to display the sign €:

  • €
  • €
  • €

Which one would you use in HTML? I think no representation is supported in all browsers. It's a pity that there is no standard way to display the sign.

Can you recommend one of the representations? What are the differences? Which ist supported best?

I hope you can help me. Thank you very much in advance!

+5  A: 

According to Google Doctype € is supported in all browsers. But maybe not all fonts.

edit I also agree with Konrad Rudolph, use the character directly if you can.

Josef
It seems that it doesn't work in Internet Explorer 8 if you use the font Courier New.
So much for "New".
innaM
A: 

I have read about this problem before. I would recomend you this web about the topis. Has a lot of info.

Jonathan
I'd say the content your link points to is outdated.
Josef
Yes, I think so, too. It's 4 years old so it doesn't say anything to the current state of browsers.
A: 

You should really just test it and specify those browsers that support it as minimum requirements. This eases your workload considerably since it makes the user responsible :-) Or, alternatively, use the word "euro" or the "EUR" curruncy designator (like USD, AUD, JPY and so on).

paxdiablo
Thank you. The "EUR" would probably be the best alternative.
+15  A: 

Which one would you use in HTML?

None of them. Use an appropriate encoding (i.e.: UTF-8 or another Unicode transform) and use the charcter directly. Do not use HTML entities if at all avoidable, since they’ve got no advantage over use of a proper encoding.

Also, this is wrong:

It's a pity that there is no standard way to display the sign.

There is, and it’s the way I’ve described. Literally every browser, down to and including MSIE 5 will display Unicode characters correctly if the chosen fond supports the glyph.

The only valid reason to not use Unicode characters and instead fall back to entities might be projects that use legacy software which doesn’t support Unicode well. But that should never happen, right?

Konrad Rudolph
Thanks! So since I use UTF-8, I should use €, right? Is this really better than the entities? Better supported?
+1. This is 2009, we should all be using UTF-8 by now. You typed the € directly in your SO question, you should type it directly in your web page!
bobince
marco: Look at my update. Yes, it is better supported, even legacy browsers display it without troubles (heck, even Lynx does, properly set up). Fonts that contain the € symbol have been around for ages and all standard web fonts (i.e. the only ones that *should* be used since they’re the only ones with sufficient widespread support) do contain it.
Konrad Rudolph
Unfortunately, it doesn't work for me. There is a box with two numbers instead of the € if I use € => http://i25.tinypic.com/bf5o55.png Why is this?
You're not using the right encoding. Use a Unicode-aware editor.
Ms2ger
I don't think that my editor (Proton) is not unicode-aware. The ä (ä) works fine for example. Only the € (€) doesn't work as you can see on the picture.
marco: That’s an encoding problem. Make sure that the encoding that is sent to the web browser corresponds with the encoding of your document/data. Feel free to open a new question if you can’t resolve this issue, since the comment space here isn’t very well suited to discuss the problem and its solutions.
Konrad Rudolph
You have saved your file as Windows-CP1252 encoding (Western European), and are serving it as ISO-8859-1 encoding, which similar to CP1252 but not the same. That's why the euro ends up as a control character (U+0080). Most likely you are serving your page without any charset data at all, so the browser is guessing which you mean, which may be confusing you. Add a <meta http-equiv="Content-Type" content="text/html;charset=..."/> element to the <head> to specify which charset you mean.
bobince
You would be best off saving the file as UTF-8 and serving it as UTF-8, but Proton is an old-fashioned editor that does not support Unicode at all. I wouldn't recommend it. Typing 'ä' to get 'ä' is just silly.
bobince
@bobince: Most browsers actually mistakenly treat ISO-8859-1 as Windows-1252 (at least on Windows), since a lot of older websites used the encoding incorrectly. At least, that was definitely true only a few years ago, in Firefox as well as MSIE. I don’t know if they’ve finally fixed that behaviour.
Konrad Rudolph
That's true. I guess the question is where Marco got the idea that ISO-8859-1 '€' (0xC2, 0x80) was the same byte sequence as UTF-8 '€' (should be 0xE2, 0x82, 0xAC). That's the point at which the confusion between cp1252 and 8859-1 happened. Marco: if you are dead set on typing bytes into your editor in cp1252 that'll come out as characters in UTF-8, the string you want is '€'. But you're better off with a proper text editor.
bobince