HTML code for an apostrophe

Viewed 541009

Seemingly simple, but I cannot find anything relevant on the web.

What is the correct HTML code for an apostrophe? Is it ’?

17 Answers

If you are looking for straight apostrophe ' (U+00027), it is

' or ' (latest is HTLM 5 only)

If you are looking for the curly apostrophe (U+02019), then yes, it is

’ or ’

As of to know which one to use, there are great answers in the Graphic Design community: What’s the right character for an apostrophe?.

It's '.

As noted by msanders, this is actually XML and XHTML but not defined in HTML4, so I guess use the ' in that case. I stand corrected.

Depends on which apostrophe you are talking about: there’s ', ‘, ’ and probably numerous other ones, depending on the context and the language you’re intending to write. And with a declared character encoding of e.g. UTF-8 you can also write them directly into your HTML: ', , .

Firstly, it would appear that ' should be avoided - The curse of '

Secondly, if there is ever any chance that you're going to generate markup to be returned via AJAX calls, you should avoid the entity names (As not all of the HTML entities are valid in XML) and use the &#XXXX; syntax instead.

Failure to do so may result in the markup being considered as invalid XML.

The entity that is most likely to be affected by this is  , which should be replaced by  

Although the ' entity may be supported in HTML5, it looks like a typewriter apostrophe. It looks nothing like a real curly apostrophe—which looks identical to an ending quotation mark: .

Just look when I write them after each other:

1: right single quotation mark entity, 2: apostrophe entity: '.

I tried to find a proper entity or alt command specifically for a normal looking apostrophe (which again, looks ‘identical’ to a closing right single quotation mark), but I haven’t found one. I always need to insert a right single quotation mark in order to get the visually correct apostrophe.

If you use just (ALT + 0146) or autoformat typewriter apostrophes and quotation marks as curly in a word processor like Word 2013, do use <meta charset="UTF-8">.

Use &apos; for a straight apostrophe. This tends to be more readable than the numeric &#39; (if others are ever likely to read the HTML directly).

Edit: msanders points out that &apos; isn't valid HTML4, which I didn't know, so follow most other answers and use &#39;.

Related