Mobile app version of vmapp.org
Login or Join
Connie430

: For web content, is it better to use an entity or the actual character? I'm confused about the correct way to insert special typographic characters (like quotation marks and em dashes) when

@Connie430

Posted in: #Html #Text #Typography #WebSafe #WebsiteDesign

I'm confused about the correct way to insert special typographic characters (like quotation marks and em dashes) when producing content that will be displayed on a web page. Is it better or preferred to type the actual unicode characters like this:

“Hello, World”


or to use entities for special characters:

“Hello, World”


Are there any risks associated with using either (specifically the risk of the user seeing some crazy character substitution), or are they truly equivalent?

10.02% popularity Vote Up Vote Down


Login to follow query

More posts by @Connie430

2 Comments

Sorted by latest first Latest Oldest Best

 

@Pierce403

Use the actual character.

The disadvantage to using entities is readability. Pop quiz: what does the following output?

†‹ some text ›

Without looking it up, I would have had no idea. Even if you did, you should consider that others reading your markup might not.

For the most part, there's no reason you shouldn't just use the actual character. To avoid any issues, be sure you're using UTF-8 everywhere. You want to be sure of the following:


The page is saved with UTF-8 encoding
The 'Content-Type' HTTP header specifies UTF-8 encoding
Data pulled from databases is saved with UTF-8 encoding
Database connections use UTF-8 encoding


There are some exceptions.


When to use escapes

Syntax characters. There are three characters that should always appear in content as escapes, so that they do not interact with the syntax of the markup. These are part of the language for all documents based on XML and for HTML.


&lt; (<)
&gt; (>)
&amp; (&)

10% popularity Vote Up Vote Down


 

@Jessie844

Now, in html5 we do not use the ascii encode anymore, but the utf-8. If you define your encode as utf-8, and you also encode the file itself in it, you will have no problems. (an old editor can not encode in utf-8, but there are a lot of free programs that do)

After that, if you need it, lets say for some programming needs, you escape it.

10% popularity Vote Up Vote Down


Back to top | Use Dark Theme