Archive for the ‘Web Design’ Category

XML Character Entities Cheat Sheet

Sunday, September 23rd, 2007

That key on your keyboard that you probably use for quotations and apostrophes isn’t actually a quotation or an apostrophe key! It’s a remnant from the typewriter era where typewriters had only a small subset of characters that were normally available in a printer’s type case. With computers and the era of desktop publishing, we’ve gone far beyond typewriters and can now be our own typesetters—you just have to know when and how to use the right characters. And trust me, your pages will look a lot spicier and much more professional when you get these down.

When writing your XML/XHTML documents you’ll want to type in these codes to get the character you want to display properly. These are called XML decimal character entities. It’s quite a mouthful, but I’ve found that they have greater support in the wild when compared to the named entities you might be familiar with such as &#ldquo;. Keep in mind that a lot of the especially tricky characters outlined below have important rules. Don’t be intimidated, just do it! Using the proper characters will spice up your documents!

Here’s a helpful little reference that I use all the time!

[—] em dash (—)
• breaks in thought
• to enclose a clause like with parentheses
• open ranges
• century vague years
• two em dashes for missing letters
• three em dashes for missing words

[–] en dash (–)
• closed numerical ranges
• indicating a connection
• showing joint authors
• compounding a hyphenation with an adjective

[‒] figure dash (‒)
• linking numbers together which are not a range
• telephone numbers

[−] minus sign (−)
• subtraction

[‐] hyphen (‐)
• joining compound words

[“] left double quotation mark (“)
• exact quotations

[”] right double quotation mark (”)
• exact quotations

[‘] left single quotation mark (‘)

[’] right single quotation mark (’)
• preferred character for use as an apostrophe

[…] ellipsis (…)
• before periods for one or more missing words
• after periods for one or more missing sentences
• with no periods for trailing thought

A lot of this information came from a great A List Apart article titled “The Trouble With EM ’n EN (and Other Shady Characters)” by Peter Sheerin as well as from a Wikipedia page on Dashes.