tags:

views:

13145

answers:

9
+7  Q: 

HTML apostrophe

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

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

+10  A: 
paxdiablo
' 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
' doesn't work in IE
Ed Griebel
+3  A: 

Here is a great reference for HTML Ascii codes:

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

The code you are looking for is: '

Tom Anderson
Strangely enough, that list doesn't have ' ???
paxdiablo
That's because ' is not part of HTML 4 (although is part of XHTML - see http://www.w3.org/TR/xhtml1/#C_16 )
msanders
+7  A: 

If you are looking for single quote, it is

'
Recep
+3  A: 

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: ', , .

Bombe
+1  A: 

' in decimal.

%27 in hex.

Yuval A
+1  A: 

As far as I know it is ' but it seems yours works as well

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

melculetz
A: 

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

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

Paul Stephenson
' 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
+7  A: 

A nice reference to characters, typography and HTML is found at A list Apart. According to that article, the correct HTML to apostrophe is ’.

mouviciel
+3  A: 

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  

belugabob