2

For example, suppose I want to put an en dash in my page title, like this:

Home – My Site

Is there any reason to use – over just putting the character in my HTML file?

Nate
  • 26,164
  • 34
  • 130
  • 214
  • Depends on the character. If it's something super weird, you might run into issues. A simple dash, however, should not break anything. – Sumner Evans Apr 30 '15 at 00:04
  • 1
    Possible duplicate of [When Should One Use HTML Entities](http://stackoverflow.com/questions/436615/when-should-one-use-html-entities) – Mogsdad Jan 14 '16 at 16:44

4 Answers4

3

It is definitely needed if you want to render characters that will mess up the HTML parser (< and >, and the & itself).

If you set the character set to UTF-8, then you can use other raw UTF8 characters.

<meta charset='utf-8'>

However some older browsers don't understand this tag, so they might not render UTF-8 characters properly.

I also wanted to point out - HTML entities are sometimes used to tell the browser to render a concept, rather than a specific character. Some browsers prefer to render entities in a more readable way than a Unicode character, for example Lynx renders &trade; as (tm) instead of

Jimmie Tyrrell
  • 1,479
  • 3
  • 12
  • 32
1

If you use the less than (<) or greater than (>) signs in your text, the browser might mix them with tags. W3Schools.com

The only other HTML entities I would probably ever use would be &nbsp; and &amp; unless a specific issue came about.

Mogsdad
  • 44,709
  • 21
  • 151
  • 275
0

If an HTML entity exists for the character you want to use, you should use the HTML entity. That ensures it displays as intended.

http://www.danshort.com/HTMLentities/index.php?w=latin

user2182349
  • 9,569
  • 3
  • 29
  • 41
-1

yes. some browsers and operating systems don't like it when you use the actual entity as it is... occasionally when typing a dash on a Mac it will just scramble or look like a void square on a Windows machine. its just safer to use the entity :D

caustic
  • 585
  • 2
  • 8
  • 18