HTML Entities - GeeksforGeeks

14 Dec, 2021
In this article, we will know HTML Entities, along with understanding their implementation through the examples. HTML provides some method to display reserved characters. Reserved characters are those characters that are either reserved for HTML or those which are not present in the basic keyboard. For instance, ‘<‘ is reserved in HTML language. Sometimes this character needs to display on the web page which creates ambiguity in code. Along with these are the characters which are normally not present in basic keyboard ( £, ¥, €, © ), etc. HTML provides some Entity names and Entity numbers to use these symbols. Entity names are case-sensitive. Entity number is easy to learn. 
Syntax:
&entity_name; or &#entity_number;
Some useful Symbols with their Entity name and Entity numbers are listed below:
Example: In this example, we have represented different entity symbols in HTML.
HTML
<!DOCTYPE html><html><body>    <h2>GeeksforGeeks</h2>    <div class="container">        <h3>Different entity symbol representation</h3>        <ul style="list-style-type:none;">            <li>                <h4>Indian currency: ₹</h4>            </li>            <li>                <h4>Euro: €</h4>            </li>            <li>                <h4>Pound: £</h4>            </li>            <li>                <h4>Yen: ¥</h4>            </li>            <li>                <h4>Dollar: $</h4>            </li>        </ul>    </div></body></html>
Output:
HTML Entities
Reserved Characters: These characters are either reserved for HTML or those which are not present in the basic keyboard & can’t use them directly.
Example: Here, a few of the reserved characters are discussed:
Other Characters: Some characters that aren’t available directly on our keyboard, therefore such an entity can be used to represent it by using their entity number. 
Example: These keywords are directly not available to type, we need to specify their entity number. Here #x before the numbers represents the hexadecimal representation.
≥
≥ ≥ &GreaterEqual;
©
&copy; ©
€
&euro;  €
∃
∃ ∃ &exist;
Example: This example illustrates the use of the special characters that are directly not available to type from the keyboard.
HTML
<!DOCTYPE html><html> <head>    <title>HTML Entities</title></head> <body>     <p>Showing euro €</p>      <p>Showing cent ¢</p>      <p>Showing Copyright ©</p>      <p>Showing BLACK DIAMOND SUIT ♦</p>      <p>Showing TRADEMARK TM</p> </body> </html>
Output:
Special Character
Advantage of HTML Entity:
Entity names can be easy to remember.
Disadvantages:
Browsers might not support all the entity names, instead, they can support the use of entity numbers.
Non-breaking Space: It is used to provide the space that will not break into a new line. This HTML entity is represented by &nbsp; that will separate the 2 words & will stick together without breaking it into a new line. We can also use the non-breaking space for preventing the browsers from truncating spaces in HTML pages. The non-breaking hyphen (‐) is used to define a hyphen character (‐) that does not break into a new line.
Example:
12:00 PM256 km/h
12:00 PM
256 km/h
If we use to write 10 spaces in our text, then the browser will remove 9 of them. In order to add real spaces in our text, we can use the character entity.
Diacritical Marks: A diacritical mark is a “glyph” added to a letter. Diacritical marks like grave ( ` ̀) and acute ( ́ ) are called accents. It can appear both above and below a letter, inside a letter, and between two letters. Diacritical marks can be used in combination with alphanumeric characters to generate a character that is not present in the character set (encoding) used on the page. Here is the list of some diacritical marks.
 ̀
a
à
à
 ́
a
á
á
̂
a
â
â
 ̃
a
ã
ã
 ̀
O
Ò
Ò
 ́
O
Ó
Ó
̂
O
Ô
Ô
 ̃
O
Õ
Õ
Supported Browser:
Google Chrome
Microsoft Edge
Firefox
Opera
Safari
Attention reader! Don’t stop learning now. Get hold of all the important HTML concepts with the Web Design for Beginners | HTML  course.
MohdArsalan
ysachin2314
bhaskargeeksforgeeks
sagartomar9927
HTML-Basics
HTML
Web Technologies
HTML
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Top 10 Projects For Beginners To Practice HTML and CSS Skills
How to insert spaces/tabs in text using HTML/CSS?
How to update Node.js and NPM to next version ?
How to set the default value for an HTML <select> element ?
Hide or show elements in HTML using display property
Remove elements from a JavaScript Array
Installation of Node.js on Linux
Convert a string to an integer in JavaScript
How to fetch data from an API in ReactJS ?
Top 10 Projects For Beginners To Practice HTML and CSS Skills