17

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?

6 Answers 6

38

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?

11
  • 1
    Thanks! So since I use UTF-8, I should use €, right? Is this really better than the entities? Better supported?
    – caw
    Sep 6, 2009 at 15:07
  • 10
    +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
    Sep 6, 2009 at 15:07
  • 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. Sep 6, 2009 at 15:09
  • 2
    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
    Sep 7, 2009 at 13:00
  • 1
    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
    Sep 7, 2009 at 13:02
9

According to Google Doctype &euro; is supported in all browsers. But maybe not all fonts.

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

1
  • It seems that it doesn't work in Internet Explorer 8 if you use the font Courier New.
    – caw
    Sep 6, 2009 at 15:55
2

From Google's HTML/CSS styleguide:

Do not use entity references. There is no need to use entity references like —, ”, or ☺, assuming the same encoding (UTF-8) is used for files and editors as well as among teams.

The only exceptions apply to characters with special meaning in HTML (like < and &) as well as control or “invisible” characters (like no-break spaces).

<!-- Not recommended -->
The currency symbol for the Euro is &ldquo;&eur;&rdquo;.

<!-- Recommended -->
The currency symbol for the Euro is “€”.
3
1

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).

1
  • 1
    Thank you. The "EUR" would probably be the best alternative.
    – caw
    Sep 6, 2009 at 15:14
0

I use &#128; as you can see here : € it works in Firefox, Chrome and IE at least.

0

The accepted answer is actually awful,at least as of today. Best choice is to use &euro;

&#128; is not Unicode, btw, even though it works. It's ANSI. JavaScript String.fromCodePoint(128) will give you a control character you won't even be able to see. Stay away from that.

If you're going to use plain UTF-8 text for symbols you might end up having mistakes after changing db properties, or if you're just typing it into file, once you accidentally copy it into an ANSI-coded, or some a file with some other encoding. Been there.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.