htmlapostrophesmart-quotes

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?


Solution

  • I don't think that one is better than the other in general; it depends on how you intend to use it.

    In general I would lean more towards using the character because as you point out it is easier to read and type.