Mar
5th

HTML Entities


When you want to display a text, you just write it into the source code. But what if you need to display some special characters like < or >? For instance, you are writing a tutorial about HTML. You will certainly need to display html tags for educational purposes. But when you just put <div> into the source code, you won’t see a thing - and it might mess up your site. I’m sure many people had to face this problem at least once.

That’s exactly a situation where HTML entities come handy. Entity is a sequence of special characters. It begins with & and ends with ;. In betwen there is a text or acronym that represents the special character / entity. The most important entity is &nbsp; which represents no-break space. It is the only way how to display more spaces on the website.

Here are some examples of entities that are used quite often:

Special character HTML entity
no-break space &nbsp;
< &lt;
> &gt;
& &amp;
® &reg;
© &copy;
± &plusmn;

There is an alternative way of insering HTML entites into the code - you can use numbers from the ASCII character set (every special character is represented by exactly one number in the ASCII table). The syntax is as follows where you substitute “number” with an actual number from the ASCII table: &#number;. For example:

Special character HTML entity
no-break space &#32;
< &#60;
> &#62;
& &#38;
® &#174;
© &#169;
± &#177;

I got one more useful thing for you - HTML character entities cheat sheet. It contains all basic characters used in Latin-1 (ISO-8859-1) character set.





You can use these XHTML tags: <a href="" title="">, <b>, <br />, <em>, <i>, <strong> and <u>