Entities in HTML

There are some reserved characters with special meanings that are used in the HTML document. To display these HTML characters as text, we have to replace them with their corresponding entities. Let us understand HTML Entities in detail.

How to Use HTML Entities?

HTML Entity is a text which starts with the ampersand (&) and ends with a semicolon (;),  It is the reserved HTML characters or known as invisible HTML codes.

  • we can replace these reserved HTML characters and characters which are not present in standard keyboard with the corresponding entity name and number.
  • For example – if you use the less than (<) or greater than (>) signs in your  HTML text, the browser might mix them and interpret it as an HTML tag that hampers the code does not allow us to display such characters in the HTML document.
  • If we have to display the character as the text we must write it as an entity for eg. for a less than sign (<)  write: &lt; or &#060;
  • Entity names are easy to remember but all web browsers do not support every entity name.
  • Entity names are case sensitive.

Syntax

&entity_name;   or  &#entity_number;
we can use either an entity name or entity number to replace the character as text on the webpage.

Useful HTML Entities

To display the characters as text some HTML Entities  of characters and mathematical symbols are shown in the following table :

Some Examples of HTML Entities

Example 1:

<!DOCTYPE html> 
<html> 
  <head> 
    <title>HTML Symbols</title> 
  </head> 
  <body> 
    <p>display of paragraph sign ¶</p> 
    <p>display of section sign §</p> 
    <p>display of careof sign  ℅</p> 
    <p>Showing TRADEMARK ™</p> 
  </body> 
</html>					 

OUTPUT: Example 2: Delta is a  greek capital letter.

Syntax : &#916;  or  &Delta;

<p> This display the sign of : Δ </p> 

OUTPUT:

Example 3:  ∑  is defined as N-ARY SUMMATION.

Syntax:   &#8721; or  &sum;

<p> This display the sign of : ∑ </p> 

OUTPUT:

Example 4: ∅  is defined as an empty set,  this sign will be display by the entity name, entity decimal value, and entity hexadecimal value.

Syntax:   &#8709;  or  &#x2205;  or   &empty;

<!DOCTYPE html>
<html>
<body>

<p> This will show &empty;</p>
<p>This will show &#8709;</p>
<p> This will show &#x2205; </p>

</body>
</html>

OUTPUT: