HTML Entities

In HTML, reserved characters must be replaced with character entities. We can also replace some characters that are not present on our keyboard with the help of entities.
Some characters like less than (<) or greater than (>) signs are reserved in HTML. If you use these signs in your text, the browser might mix them with tags. Therefore we use character entities to display reserved characters in an HTML document.
In an example below this is how character entity looks like:
Example
&entity_name ;
or
&#entity_number ;
It’s better to use entity number instead of entity name, because browsers do not support all entity names.
Note:- Don’t forget to add semicolon at the end of entity name or number.
How to use an entity in an HTML
In an example below let’s see how you can use entity name and number in HTML:
Example
<!DOCTYPE html> <html> <body> <h2> HTML Entity Example </h2> <!--by name --> <p> This is a less than sign: < </p> <!-- by number --> <p> This is also a less than sign : < </p> </body> </html>
Some Commonly Used HTML Character Entities
Description | Entity Name | Entity Number | Result |
---|---|---|---|
Less than | < | < | < |
Greater than | > | > | > |
Single quotation mark | ' | ' | ‘ |
Double quotation mark | " | " | “ |
ampersand | & | & | & |
non-breaking space | | &160; | |
cent | ¢ | ¢ | ¢ |
pound | £ | &3163; | £ |
yen | ¥ | ¥ | ¥ |
euro | € | € | € |
copyright | © | © | © |
registered trademark | ® | ® | ® |
Related Posts
HTML Entities – crus4
3 thoughts on “HTML Entities – crus4”