HTML-Lesson 18

Entities

Introduction

One of the strengths of HTML is that it can be composed and edited in a straightforward text editor. This is also a weakness. What happens, you may ask, if you want to display any of the special characters needed for HTML tags. Characters like '<' and '>'. Well, there is a simple but long-winded way to do so. This method can also be used to display characters not normally accessible. You used to be able to use this method to display email addresses in a way that fools the programs that trawl the Internet gathering addresses for spammers.

The method is to enclose the data for the these special characters within an ampersand and a semi-colon. E.G. &lt; and &gt;. Now that the ampersand is used for special characters, it becomes a special character itself and is represented by &amp;. Alternatively characters can be coded as an ampersand followed by a hash sign, a number and a semi-colon. In the tables in the next lesson, only the numbers are given.

Another entity which should be mentioned is the pound sign, £, which is written as '&pound;'. Using a pound sign straight off the keyboard is not advised as it will display as something else in other countries! Some authors use 'GBP'.

Some special characters

Here are some special characters which are not really available in any other way!

namedisplaywrite
less than   <&lt;
greater than       >&gt;
ampersand   &&amp;
pound   £&pound;
degree   °&deg;
copyright   ©&copy;
trade mark   ™&trade;
space   &nbsp;

Note.

This space is known as a 'non-breaking space'. It is one of the only two ways in HTML to write two or more consecutive spaces.

Previous Lesson previous lesson next lesson Next Lesson