[html] HTML Best Practices: Should I use ’ or the special keyboard shortcut?

I know that ’ will produce an apostrophe in an HTML document.

I also know that option shift right bracket on a Mac will simply produce a character.

Are there best practices for writing code, e.g., should I write

<b>The User&rsquo;s Forum</b>

or

<b>The User’s Forum</b>

(note that by using the keyboard shortcut I've been able to type instead of ' above)

It strikes me that the latter (using the keyboard shortcut) is more robust, as it's not likely to display the raw HTML if, for example, it's not escaped.

On the other hand, the special ’ character may not be readable in some browsers, perhaps(?).

Anyone have any best practices on this?

This question is related to html apostrophe smart-quotes

The answer is


Typographically, the correct glyph to use in sentence punctuation is the quote mark, both single (including for apostrophes) and double quotes. The straight-looking mark that we often see on the web is called a prime, which also comes in single and double varieties and has limited uses, mostly for measurements.

This article explains how to use them correctly.


You should only use &rsquo; if your intention is to make either a closed single quotation mark or an apostrophe. Both of these punctuation marks are curved in shape in most fonts. If your intent is to make a foot mark, go the other route. A foot mark is always a straight vertical mark.

It’s a matter of typography. One way is correct; the other is not.


One risk of using the keyboard shortcut is that it requires using a non-ASCII encoding. That might be fine, but if your source is loaded by different editors in different locales, you might hit trouble somewhere along the line.

It might be safer to use either &#8217; or &rsquo; (which are equivalent) as both are ASCII.


If your text will be consumed by non-browsers then it's safer to type the character with the keyboard-combo option shift right bracket because &rsquo; will not be transformed into an apostrophe by a regular XML or JSON parser. (e.g. if you are serving this content to native Android/iOS apps).


With &rsquo; you know for certain that the output will be correct, no matter what.

I wish &apos; would output the proper apostrophe and not the typewriter apostrophe.