246

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

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

Tot Zam
  • 8,406
  • 10
  • 51
  • 76
Chris J Allen
  • 18,970
  • 20
  • 76
  • 114
  • 4
    8217 is for a right single quotation mark. – Tom Anderson Jan 07 '09 at 09:36
  • 10
    @Josh Stodola what if its in JavaScript? It will close the tag :) –  Nov 12 '09 at 14:20
  • 9
    you can type \' :-) but use ’ – Aziz Jun 03 '10 at 13:39
  • 4
    @TomAnderson That is true, `’` is for a right single quotation mark – and it is also for an apostrophe. They use the same symbol. – Rory O'Kane Jun 18 '12 at 17:45
  • 39
    There are important differences between quotes, apostrophes, and other symbols like degrees and minutes and inches and feet. Even if they look the same ' and '' to you, that depends on the fonts. It also depends on the application. For instance word processors in French change quotes to guillermets like << and >> , and the placement of curly quotes low or high also varies between languages. Similar problems come up with hyphens and dashes, and a line-break hyphen is not the same as a word-formation hyphen, and a minus sign is quite another thing again. Programming languages which hiccup when a –  Jun 25 '12 at 13:45
  • Actually, what if he is not only using JavaScript, but pulling the data from a json file? In this case, which I am facing, I can't use ' or \'. If I try to use the JavaScript escape character, it breaks the jQuery library somewhere. If I simply use the apostrophe, it (as stated above) closes the tag. Because of this, I have to use an html entity code. – VoidKing Jan 31 '13 at 16:39
  • check out this resource i just found http://amp-what.com/unicode/search/quote – Kieran Sep 13 '13 at 00:11
  • You can copy and paste the character ( ’ )as well, that works in most text editors, this way you don't have to worry about it being ever shown as `’`. – aaron-coding Sep 03 '15 at 19:43
  • Don't use U+2019 RIGHT SINGLE QUOTATION MARK instead of an apostrophe since it will confuse programs which finds quoted text. – beroal Nov 18 '21 at 06:50
  • If you are searching for the apostrophe that is used in Markdown to enclose code `\``, then the HTML code is ``` – Avatar Apr 21 '22 at 14:42
  • @Avatar that is not an apostrophe. That's a backtick – qwr Aug 06 '23 at 05:16

17 Answers17

337

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

&#39; or &apos; (latest is HTLM 5 only)

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

&#8217; or &rsquo;

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?.

Capripot
  • 1,354
  • 16
  • 26
Recep
  • 18,991
  • 2
  • 28
  • 21
  • 11
    My boss just made me change all the single quote on our site to a proper typographic apostrophe. The ' is technically not an apostrophe according to a her... however W3C does view it as an apostrophe. I saw to hell with the proper English and typography a ' is a ’ to most people. – Cleanshooter Mar 08 '12 at 17:12
  • 148
    The question says “apostrophe”, not “single quote”. If you already know you want an apostrophe, you might as well use the proper apostrophe `’` (’). It does no harm and will make some readers happier. – Rory O'Kane Jun 18 '12 at 17:34
  • 19
    `'` is the "mixed-use" ascii apostrophe/single quote. But the [Unicode standard](http://unicode.org/Public/UNIDATA/NamesList.txt) says you should prefer `’` for apostrophe and right single quote and `‘` for left single quote. – Bennett McElwee Jul 04 '13 at 01:59
  • 13
    Comment by [Conexion](http://stackoverflow.com/users/689129/conexion) from the edit I rejected: "If you are using HTML5, an apostrophe is defined in the [spec](http://www.w3.org/TR/html5/syntax.html#named-character-references) as `'` . If you are wanting a more backward-compatible code (`'` is not valid in HTML4), use: `’`" – Vi. May 06 '14 at 21:39
  • 4
    Most folks who find this page are probably looking for `’` for use in contractions, e.g. can’t. See Joseph’s answer below for more. – Liam Jun 09 '18 at 23:01
106

A List Apart has a nice reference on characters and typography in HTML. According to that article, the correct HTML entity for the apostrophe is &#8217;. Example use: ’ .

mouviciel
  • 66,855
  • 13
  • 106
  • 140
  • 15
    You can also use `’` or `’` in place of `’`. I happen to find the mnemonic version a little easier to read. The hex version is easier for looking up in Unicode code charts. – Ted Hopp Jun 27 '11 at 22:31
  • 5
    The [Unicode standard](http://unicode.org/Public/UNIDATA/NamesList.txt) says that `’` is "preferred" over `'` for the apostrophe. – Bennett McElwee Jul 04 '13 at 01:52
  • 1
    Thanks for the reference from unicode.org, @BennettMcElwee. As for me, I would certainly "prefer" that the apostrophe and the right single quote be treated as distinct glyphs if they're semantically distinct, so `'` remains the best choice IMO. Basically, it seems that some people don't like it for not being curly enough (as a token of typographic seriousness, I dunno...) but that's beside the point. – Nicolas Le Thierry d'Ennequin Nov 24 '14 at 09:41
  • 4
    They don’t go into much detail, but: "A note from the editors: This article, while brilliant for its time, is now obsolete.” The article was published Oct 2001. – duozmo Feb 13 '15 at 17:13
  • It's worth noting that this is actually a right-single-quote. But it seems that that is ok according to wikipedia: http://en.wikipedia.org/wiki/Apostrophe#Entering_apostrophes – matt burns Feb 24 '15 at 10:52
41

It's &apos;.

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

Tot Zam
  • 8,406
  • 10
  • 51
  • 76
paxdiablo
  • 854,327
  • 234
  • 1,573
  • 1,953
  • 10
    ' is not a valid HTML 4 entity. It is part of XML and so is part of XHTML 1.0. See: http://www.w3.org/TR/xhtml1/#C_16 – msanders Jan 07 '09 at 10:53
  • You need to use ' not &39; . The number symbol makes it show up, otherwise it is just written out. Also, there is a word entity for it, but that is not technically valid in earlier HTML versions thanks to a typo by the W3C (though most browsers support the word version anyways, but I cannot remember what it is). – tomysshadow May 24 '14 at 19:56
20

A standard-compliant, easy-to-remember set of html quotes, starting with the right single-quote which is normally used as an apostrophe:

  • right single-quote — &rsquo; — ’
  • left single-quote — &lsquo; — ‘
  • right double-quote — &rdquo; — ”
  • left double-quote — &ldquo; — “
Joseph Hansen
  • 12,665
  • 8
  • 50
  • 68
19

Depends on which apostrophe you are talking about: there’s &apos;, &lsquo;, &rsquo; 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: ', , .

Bombe
  • 81,643
  • 20
  • 123
  • 127
  • 4
    This answer is correct, except for the `‘`, which is in no way an apostrophe. – Nicolas Barbulesco Nov 15 '13 at 12:39
  • "And with a declared character encoding of e.g. UTF-8 you can also write them directly into your HTML". That's very interesting - I didn't know that! I'd be interested to see a source for that if you have one. – Sam Sep 17 '14 at 08:02
12

Firstly, it would appear that &apos; should be avoided - The curse of &apos;

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 &nbsp;, which should be replaced by &#160;

belugabob
  • 4,302
  • 22
  • 22
6

Note that &apos; IS defined in HTML5, so for modern websites, I would advise using &apos; as it is much more readable than &#39;

Check: http://www.w3.org/TR/html5/syntax.html#named-character-references

HammerNL
  • 1,689
  • 18
  • 22
6

Here is a great reference for HTML Ascii codes:

http://www.ascii.cl/htmlcodes.htm

The code you are looking for is: &#39;

Tom Anderson
  • 10,807
  • 3
  • 46
  • 63
  • 2
    That's because ' is not part of HTML 4 (although is part of XHTML - see http://www.w3.org/TR/xhtml1/#C_16 ) – msanders Jan 07 '09 at 11:15
6

Sorry if this offends anyone, but there is a reasonable article on Ted Clancy's blog that argues against the Unicode committee's recommendation to use &#8217; (RIGHT SINGLE QUOTATION MARK) and proposes using U+02BC (MODIFIER LETTER APOSTROPHE) (aka &#700; or &#x2bc;) instead.

In a nutshell, the article argues that:

  • A punctuation mark (such as a quotation mark) normally separates words and phrases, while the sides of a contraction really can't be separated and still make sense.
  • Using a modifier allows one to select a contraction with the regular expression \w+
  • It's easier to parse quotes embedded in text if there aren't quotation marks also appearing in contractions
Mike Godin
  • 3,727
  • 3
  • 27
  • 29
  • I agree that semantically it makes sense that it should be U+02BC but unfortunately it's rendered as a straight angled single quote in most fonts, instead of the curly one. – Brian Minton Dec 22 '21 at 13:53
6

Even though &apos; reads nicer than &#39; and it's a shame not to use it, as a fail-safe, use &#39;.

&apos; is a valid HTML 5 entity, however it is not a valid HTML 4 entity.

Unless <!DOCTYPE html> is at the top of your HTML document, use &#39;

WonderWorker
  • 8,539
  • 4
  • 63
  • 74
3

Although the &apos; 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">.

3

I've found FileFormat.info's Unicode Character Search to be most helpful in finding exact character codes.

Entering simply ' (the character to the left of the return key on my US Mac keyboard) into their search yields several results of various curls and languages.

I would presume the original question was asking for the typographically correct U+02BC ʼ, rather than the typewriter fascimile U+0027 '.

The W3C recommends hex codes for HTML entities (see below). For U+02BC that would be &#x2bc;, rather than &#x27; for U+0027.

http://www.w3.org/International/questions/qa-escapes

Using character escapes in markup and CSS

Hex vs. decimal. Typically when the Unicode Standard refers to or lists characters it does so using a hexadecimal value. … Given the prevalence of this convention, it is often useful, though not required, to use hexadecimal numeric values in escapes rather than decimal values…

http://www.w3.org/TR/html4/charset.html

5 HTML Document Representation5.4 Undisplayable characters

…If missing characters are presented using their numeric representation, use the hexadecimal (not decimal) form, since this is the form used in character set standards.

Community
  • 1
  • 1
2540625
  • 11,022
  • 8
  • 52
  • 58
  • Is this website affiliated with the official Unicode? – Pacerier Mar 30 '17 at 03:09
  • The site FileFormat.info is maintained independently by an individual. I simply find its search to be easiest to use. See also the site's About/FAQ page: http://www.fileformat.info/about/faq.htm – 2540625 Apr 03 '17 at 22:43
3

Just a one more link with a nicely maintained collection Html Entities (archived), and its current (2023-01-22) status Named Character References.

albert
  • 8,112
  • 3
  • 47
  • 63
DeltaCap019
  • 6,532
  • 3
  • 48
  • 70
3

&#39; in decimal.

%27 in hex.

Yuval Adam
  • 161,610
  • 92
  • 305
  • 395
2

As far as I know it is &#39; but it seems yours works as well

See http://w3schools.com/tags/ref_ascii.asp

melculetz
  • 1,961
  • 8
  • 38
  • 51
2

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;.

Paul Stephenson
  • 67,682
  • 9
  • 49
  • 51
  • 1
    ' is not a valid HTML 4 entity. It is part of XML and so is part of XHTML 1.0. See: http://www.w3.org/TR/xhtml1/#C_16 – msanders Jan 07 '09 at 10:54
1

You can try &#x0027; as seen in http://unicodinator.com/#0027

Junior Mayhé
  • 16,144
  • 26
  • 115
  • 161