Home

Using HTML Entities

|
Updated:  
2016-03-26 13:57:27
|
HTML5 and CSS3 All-in-One For Dummies
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 x5.

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 earned a degree in Special Education from Indiana University/Purdue University–Indianapolis (IUPUI). He taught young adults with severe disabilities for several years. He also taught himself enough computer programming to support his teaching habit with freelance programming.
Those were the exciting days when computers started to have hard drives, and some computers connected to each other with arcane protocols. He taught programming in those days because it was fun.
Eventually, Andy decided to teach computer science full time, and he still teaches at IUPUI. He lectures in the applied computing program and runs the streaming media lab. He also teaches classes in whatever programming language is in demand at the time. He has developed a large number of online video-based courses and international distance education projects.
Andy has written several books on various computing topics and languages including Java, C#, mobile computing, JavaScript, and PHP/MySQL.
Andy welcomes comments and suggestions about his books. He can be reached at [email protected].