HTML5 and CSS3 All-in-One For Dummies
Book image
Explore Book Buy On Amazon

HTML is a terrific tool for writing documents, but every once in a while, you come across a character that can't easily be printed in HTML. For example, what if you're writing about math and you want to use the less than (<) symbol? HTML normally interprets the less than symbol as the beginning of an HTML tag.

Likewise, you might find yourself wanting to use the yen sign, adding an inverted exclamation point for text written in Spanish, or some other unique character.

HTML has a special feature for adding these characters, called HTML entities. An HTML entity is a special code embedded in a website. When the browser sees the code, it replaces it with a special character.

All HTML entity codes begin with the ampersand (&) and end with a semicolon (;). In between is a text code describing the particular symbol. For example, use x < 5 to create the output x<5.

In addition to the shortcut, you can use the ASCII/Unicode equivalent to print most characters found in the standard ASCII or Unicode (ISO-9959-1) character sets. The less than symbol is also ASCII character 60, so you could also use this as well: x < 5.

All HTML-compliant browsers are required to support the following entities, which are all reserved characters in HTML.

Character Entity ASCII/Unicode
" " "
& & &
' ' '
< < <
> > >

Most modern browsers support many other HTML entities as well. Here are a few other symbols you might want to use:

Entity Character
  Non-breaking space. Forces a space.
¡ Inverted exclamation point (¡)
¿ Inverted question mark (¿)
¢ Cent sign (¢)
£ Pound sign (£)
¥ Yen sign (¥)
© Copyright symbol (©)
® Registered trademark (®)
° Degree symbol (°)
× Multiplication symbol (×)
÷ Division symbol (÷)

You can find a full list of HTML entities at HTMLEntities.net.

About This Article

This article is from the book:

About the book author:

Andy Harris taught himself programming because it was fun. Today he teaches computer science, game development, and web programming at the university level; is a technology consultant for the state of Indiana; has helped people with disabilities to form their own web development companies; and works with families who wish to teach computing at home.

This article can be found in the category: