In this tutorial , we are going to learn how to use HTML entities to display special characters and symbols on your web page.
Let’s begin the tutorial with defining what entities are. There are many characters reserved in HTML which we cannot directly use by text because of various reasons like, maybe the character is not present in the keyboard or the character maybe part of the markup language.
To display such special characters we use character entities. These entities enable you to use the characters that cannot be expressed in the document’s character encoding or that cannot be entered by a keyboard.
Entities represent arrows, letters, currencies, mathematical operators, numbers, punctuation marks, symbols, shapes and many more. Two of the most extensively used characters are a copyright character – © or a heart symbol – ♥
An entity begins with “&” ampersand sign and ends with a “;” semicolon. And in between & and ; we can write entity name, hexadecimal code or a decimal code depending on the character you want.
Some frequently used entities are listed below:
Output | Description | Entity Name | Entity Number |
---|---|---|---|
non-breaking space | |   | |
< | less than | < | < |
> | greater than | > | > |
& | ampersand | & | & |
“ | double quotation mark | " | " |
‘ | single quotation mark (apostrophe) | ' | ' |
¢ | cent | ¢ | ¢ |
£ | pound | £ | £ |
¥ | yen | ¥ | ¥ |
€ | euro | € | € |
© | copyright | © | © |
® | registered trademark | ® | ® |
Numerical references have browser support and can be used to specify any Unicode character, on the other hand entities are limited to a subset of this.
We don’t need to add any extra libraries to access these characters. And entities are strings because of which we can apply different implementations like HTML, CSS and JavaScript.
There are hundreds of entities available and you can always search on the web whenever you are stuck on some character that’s new to you.
Hope you have understood what entities are.