demosthenes.info

A blog by Dudley Storey on , , , , , , and anything else that strikes his fancy.

featured articles

popular favourites

HTML Entities

There are two primary methods of generating a character with HTML entities: that is, two ways of generating characters that your keyboard and/or a word processor does not produce by default. Both methods start with an ampersand character (&) and end with a semi-colon. They are keyword and decimal entities.

Keyword entities

Keyword entities cover the most common characters, and are recognized by the majority of browsers. A few examples:

Keyword HTML entities
KeywordMeaningProduces
©copyright symbol©
™trademark symbol
°degree°
&mash;a long dash – to separate two conjoined pieces of text
‐a short dash or hyphen - to join words or dates (e.g. 1939-45)
“a leading quotation mark
”a closing quotation mark
″inches, seconds
′feet, minutes
¾three-quarters¾

Decimal entities

Not every character has a keyword entity: the number of possible characters and symbols from every language is simply too great. Every character is also given a decimal entity: a code written in numbers. Sometimes these have keyword entity equivalents, but often not. Successful glyph representation is often more sensitive to font, browser, and OS selection. A minute sampling:

Decimal HTML entities
CodeMeaningProduces
↺open circle clockwise arrow
⇨right white arrow
⅗vulgar fraction, three-fifths
№numero sign
Ωohm

A few oddities

There are a few characters that remain problematic. The first two are the greater and less than sign: when you use < or > in a web page, the browser will assume that you are starting about the start or end of a tag. Use the keyword entities &lt; and &gt; to create those.

The last is the ampersand character, for similar reasons – if we have an & in our document, the browser assumes we are going to start an HTML entity. You have a keyword entity for that too: &amp;

web developer guide

featured comment

by JoelB in Goodbye, JQuery Validation: HTML5 Form Errors With CSS3

what i'm reading

A Storm of Swords: A Song of Ice and Fire: Book Three
A Storm of Swords: A Song of Ice and Fire: Book Three

what i'm watching

Californication: The Third Season
Californication: The Third Season

what i'm playing

Mass Effect 3 Collector's Edition
Mass Effect 3 Collector's Edition

what i'm hearing

Dub FX
Dub FX

blogs

podcasts

no ads ever

This blog is free of advertising, and always will be.

creative commons licensed

The content of this blog is free to use in whatever way you wish under the Creative Commons license.