0

I am wondering, if I can use html-entities like

<h5><em>⇆</em> Headline</h5>

without any fallback if I use utf-8? (because on my systems this works totally fine). Are all these chars from http://dev.w3.org/html5/html-author/charref really all embedded into the utf-8-charset by default?

And how would I use it correctly, like this:

<h5><em>⇆</em> Headline</h5>

that

<h5><em>&lrarr; </em> Headline</h5>

or

<h5><em>&#8646;</em> Headline</h5>
Daiaiai
  • 1,019
  • 3
  • 12
  • 28

1 Answers1

1

There are two separate issues here:

  1. get the browser to understand which character you want
  2. render that character visually

For the first point, there are two options:

  1. Embed the character directly as is, for which you will need to serve the HTML in an encoding that can encode that character. Yes, "⇆" is a Unicode character and can be encoded by any Unicode encoding. UTF-8 is the best choice here. The browser then simply needs to understand that the document is encoded in UTF-8 and it will be able to read and understand the character correctly. Set the appropriate HTTP header to denote the encoding.
  2. Embed the character as an HTML entity. HTML entities is a way to embed any arbitrary character using only ASCII characters, e.g. &lrarr;. To encode this, your encoding of choice only needs to be able to encode &, l, r, a and ;, which are very standard characters in any encoding. This special sequence of characters is understood by the browser to mean the character "⇆". By embedding characters as HTML entities you can largely ignore the intricacies of managing encodings correctly, but it makes your source code rather unreadable. You should not do this in this day and age.

    Whether you use named entities (&lrarr;) or refer to the character by its Unicode code (&#8646;) doesn't really matter, they both result in the same thing.

Having handled this, the character needs to be actually rendered as a glyph on screen. For this, an appropriate font is necessary. You'll have to test whether most of your target audience uses a system which has a font installed by default which contains this character. You can also provide your own font to the browser which contains this character as a web font.

Community
  • 1
  • 1
deceze
  • 510,633
  • 85
  • 743
  • 889