File Under: HTML

Write Symbols and Special Characters in HTML

When you type regular letters, numbers, and characters from your keyboard into the body of an HTML document, they show up on your Web pages just as you typed them. But things aren’t so easy in non-English speaking countries (and such places do exist – honest). Languages such as French, German, and Icelandic often use characters that are not found on your typical keyboard. Even in English, accents can distinguish a “résumé” from a “resume.”

So how do you make special characters and accented letters show up on your pages? You use a special set of codes called character entities, which you insert into your HTML code and which your browser will display as the corresponding symbols or characters you want.

The most common character entities have been collected by the International Organization for Standardization and compiled in the Special Characters ISO Latin Alphabet No. 1 table, which includes special characters, letters with diacritical marks (accents, umlauts, etc.), and scientific and currency symbols. The Latin-1 table contains 255 characters.

There are two kinds of entities here: text and numeric. Both kinds begin with an ampersand (&) and end with a semicolon (;).

The text entities use letters to represent a character, and they’re designed to be easy to remember. So say you wanted to have the following sentence appear on your Web page:

"The © symbol stands for 'copyright.'"

Your HTML code would look like this:

"The © symbol stands for 'copyright.'"

Numeric entities are similar to text ones, but should be written in this form:&#x; – where the “x” represents a number between 0 and 255. It is very important to make sure that the # symbol precedes the number, or the entity will not work. So to make “The © symbol stands for ‘copyright.’” with a numeric entity, your HTML would look like this:

"The © symbol stands for 'copyright.'"

As you can see, some characters (like ©) can be represented by either a text or a numeric entity.

A note of caution here:Many computers let you use keyboard shortcuts to create accented letters and special characters (for example, typing option + e will produce “é”). Beware, the shortcuts may not always work. The browser may read the character you created differently or not at all. This occurs because the code that is used to represent the character on the keyboard does not directly translate into Latin-1 and probably won’t be read by your Web browser.

Sometimes, case can also be important. For example, é produces the é character, while É results in É.

So, that’s entities in a nutshell. Keep in mind that not all entities are recognized by older browsers. You may want to bookmark our ISO entities page for future reference.