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: < or <
- Entity names are easy to remember but all web browsers do not support every entity name.
- Entity names are case sensitive.
&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
<!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 : Δ or Δ
<p> This display the sign of : Δ </p>
Example 3: ∑ is defined as N-ARY SUMMATION.
Syntax: ∑ or ∑
<p> This display the sign of : ∑ </p>
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: ∅ or ∅ or ∅
<!DOCTYPE html> <html> <body> <p> This will show ∅</p> <p>This will show ∅</p> <p> This will show ∅ </p> </body> </html>