Question

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!

Was it helpful?

Solution

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?

OTHER TIPS

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.

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 “€”.

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

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

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top