Basic Examples

So you want to encode an apostrophe in your HTML documents? Here's how:

The Official, Recommended Way: HTML Entity Number

The official, recommended way to encode an apostrophe in your HTML documents is by using what is called an "HTML Entity Number". The HTML Entity Number looks like this:


This entity number, when placed in an HTML document, will be rendered as an apostrophe in web browsers. This entity number is the official, universal and documented method of encoding HTML apostrophes in your code.

An Unofficial, Discouraged but Easy-To-Remember Way: HTML Entity Name

A similar and slightly easier-to-remember way of encoding apostrophes in your HTML documents is by using what is called an "HTML Entity Name". The entity name looks like this:


If you are writing HTML code and don't want to look up the entity number of an apostrophe, you can use this entity name instead.

However, this entity name is not an official entity name in HTML. It is only an official entity name in XML. Therefore, using this entity name within HTML is highly discouraged. While this entity name may render properly in current versions of Chrome and Firefox, it is known that in Internet Explorer 8, this entity name does not render properly.

The Easiest Way: Just Type an Apostrophe

Of course, the easiest way to display an apostrophe within your HTML documentsis to simply type one, like so:


The apostrophe key is directly left of the Enter key on your keyboard.

If you are writing basic text, then simply typing an apostrophe in your HTML is generally okay. Encoding apostrophes only becomes more important when writing text that is used within surrounding code such as HTML attributes or JavaScript.

But Wait, There's More

You would think that typing an apostrophe within an HTML document would be extremely simple and rudimentary. Unfortunately, this is not the case, and there are more advanced apostrophes to be aware of.