Design & UX
By Jason Beaird

Special Entities of HTML

By Jason Beaird

When you type text into any reasonably modern word processing program, even though your keyboard key shows that ubiquitous ASCII double quote symbol, you see nice “curly” opening and closing punctuation marks when you hit it.

These special quotes can’t be found on your keyboard. But word processing programs understand that when you put something in quotes, you want nice left and right quotes, and it replaces the characters you typed in with the correct ones. The same goes with apostrophes. Have you ever seen an ASCII apostrophe like the one on your keyboard in a book or brochure? Of course not. What we usually see in printed material is a closing single quote. In fact, there exists a vast array of characters that aren’t represented on a standard keyboard, though these characters show up on web pages and in printed material.

Now, that’s all well and good for people using word processors. But for those of us typing text into an HTML document, there’s no system to automatically replace the characters from our keyboards with their grammatically correct equivalents. Depending on which type of character encoding your web site uses, when you paste these characters directly into an HTML document, you may see a bunch of gibberish on the rendered page. Also, the inclusion in text of characters that are used by HTML, like < and >, will wreak havoc in your page, as they cause the beginning or ending of HTML code.


For these reasons, a series of special codes or entities has been created—we type these into our HTML documents to produce correct punctuation marks and just about any special character that we could need. The examples in the table below are just a sample of the many HTML character codes that exist.

The code on the far left is known as an entity name or keyword. For instance, to produce a copyright symbol in your document, enter copy directly into your HTML; you’ll see a © in the rendered page. Each of these entities also has a numerical equivalent; the numerical equivalent of copy is #169 which produces the same symbol.

Sample list of HTML character entity references

Entity Character Description
&lt; < Less than
&gt; > Greater than
&amp; & Ampersand
&lsquo; Left single quote
&rsquo; Right single quote
&ldquo; Left double quote
&rdquo; Right double quote
&laquo; « Left angle quote
&raquo; » Right angle quote
&reg; ® Registered trademark
&trade; Trademark
&copy; © Copyright
&cent; ¢ Cent
&pound; £ Pound
&euro; Euro
&yen; ¥ Yen
&frac14; ¼ One quarter
&frac12; ½ One half
&frac34; ¾ Three quarters

For a more complete list of codes and their alternative entity numbers, check out W3Schools’ HTML Entities page.

We’ve all had adventures using special characters online. What pitfalls have you fallen prey to? And what advice can you give to help others avoid them?

The most important and interesting stories in tech. Straight to your inbox, daily. Get Versioning.
Login or Create Account to Comment
Login Create Account