Cameron
Cameron

Reputation: 28803

Correct type of apostrophe to use in HTML

If I write a paragraph using my keyboard straight into a text editor for a HTML document and one of the words has an apostrophe then the apostrophe will be written exactly like this:

Here's an example of some text.

However if copying from Word, the same sentence would appear as:

Hereʼs an example of some text.

What's the correct way to show them in a HTML document? As I normally do a find and replace to make them the same as '.

Additionally I can also write them using encoding:

ʼ = ʼ

&pos; = '

' = '

Is there a standard way of doing this? I understand that &pos; is a HTML5 thing so ' might be the safer option but do you need to escape them? And which apostrophe should be used?

Upvotes: 3

Views: 7522

Answers (1)

Quentin
Quentin

Reputation: 943571

do you need to escape them?

The ' character needs to be represented by an entity only if it appears in an attribute value delimited by ' characters.

The ʼ character needs to be represented by an entity only if the document is encoded using a character encoding which does not include it. You should not be using such a character encoding this century (because Unicode support is ubiquitous).

And which apostrophe should be used?

That's a typography question (not apropriate for Stackoverflow) and largely a matter of opinion.

Upvotes: 2

Related Questions