The Wayback Machine - https://web.archive.org/web/20240709182307/https://www.geeksforgeeks.org/html-entities/
Open In App

HTML Entities

Last Updated : 21 May, 2024
Improve
Improve
Like Article
Like
Save
Share
Report

HTML entities offer methods to display reserved characters, ensuring correct rendering. Reserved characters, like ‘<‘, can create ambiguity if not displayed properly. HTML provides entity names and numbers for symbols not on basic keyboards (e.g., £, ¥, €, ©), resolving ambiguity and enabling accurate display.

Syntax

&entity_name; or & #entity_number;

Note: Entity names are case-sensitive.

Entity Name and Entity Number

Some useful Symbols with their Entity name and Entity numbers are listed below:

Notation

Symbols

Entity name

Entity Number

 non-breaking space&nbsp; 
<less than&lt;<
®registered trademark&reg;®
©copyright&copy;©
€euro&euro;€
¥yen&yen;¥
£pound&pound;£
¢cent&cent;¢
“double quotation mark&quot;“
&ampersand&amp;&
>greater than&gt;>
∂PARTIAL DIFFERENTIAL&part;∂
∃THERE EXISTS&exist;∃
∅EMPTY SETS&empty;∅
∇NABLA&nabla;∇
∈ELEMENT OF&isin;∈
∉NOT AN ELEMENT OF&notin;∉
+PLUS SIGN&plus;+
∏N-ARY PRODUCT&prod;∏
∑N-ARY SUMMATION&sum;∑
ΑAlpha&Alpha;Α
ΒBeta&Beta;Β
ΓGamma&Gamma;Γ
Δdelta&Delta;Δ
ΕEpsilon&Epsilon;Ε
ΖZeta&Zeta;Ζ
♥BLACK HEART SUIT = valentine&hearts;♥
♣BLACK CLUB SUIT = shamrock&clubs;♣
♠BLACK SPADE SUIT&spades;♠
↓DOWNWARDS ARROW&darr;↓
→RIGHTWARDS ARROW&rarr;→
↑UPWARDS ARROW&uarr;↑
←LEFTWARDS ARROW&larr;←
™TRADEMARK&trade;™
♦BLACK DIAMOND SUIT♦♦
°degree&deg;°
∞infinity&infin;∞
‰per-mille&permil;‰
⋅dot operator&sdot;⋅
±plus-minus&plusmn;±
†hermitian&hercon;⊹
–minus sign&minus;−
¬–&not;¬
%percent sign&percent;%
fFunction&fnof;ƒ
∥parallel&parallel;∥

Examples of HTML Entities

Example: In this example we displays various currency symbols using entity representations.

HTML
<!DOCTYPE html>
<html>

<body>
    <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

HTML Entities Example output

Reserved Characters

These characters are either reserved for HTML or those which are not present in the basic keyboard & can’t use them directly. Some of the reserved characters representations are given below:

Reserved Character

Entity Name

&&amp;
<&lt;
>&gt;
“&quot;

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. These keywords are directly not available to type, we need to specify their entity number. Here #x before the numbers represents the hexadecimal representation.

Character

Entities

≥

&GreaterEqual;

©

&copy; 

€

&euro;  

∃

&exist;

Example: Illustration of the use of 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 &euro;</p>
    <p>Showing cent &cent;</p>
    <p>Showing Copyright &copy;</p>
    <p>Showing BLACK DIAMOND SUIT &diams;</p>
    <p>Showing TRADEMARK &trade;</p>
</body>

</html>

Output:

Special Character

Advantages and Disadvantages of HTML Entity

Advantages

  • 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 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 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.

Combining 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.

Symbols

Character

Construct

Final Result

 ̀

a

à

à

 ́

a

á

á

̂

a

â

â

 ̃

a

ã

ã

 ̀

O

Ò

Ò

 ́

O

Ó

Ó

̂

O

Ô

Ô

 ̃

O

Õ

Õ

Supported Browser



Previous Article
Next Article

Similar Reads

Adding HTML entities using CSS content
HTML provides some method to display reserved character. Reserved characters are those characters which are either reserved for HTML or those which are not present in the basic keyboard. For Example: '&lt;' is already reserved in HTML language. Sometimes this character needs to display on the web page which creates ambiguity in code. Along with the
2 min read
What is character entities in HTML ?
In this article, we will learn about HTML character entities and how to use them. HTML character entities are basically a set of characters (entity) used to represent few characters reserved by the HTML, especially invisible characters or characters difficult to type out using a regular keyboard. HTML provides some entity names and entity numbers t
2 min read
How to Convert Special HTML Entities Back to Characters in PHP?
Sometimes, when we work with HTML in PHP, you may encounter special characters that are represented using HTML entities. These entities start with an ampersand (&amp;) and end with a semicolon (;). For example, &amp;lt; represents &lt;, &amp;gt; represents &gt;, and &amp;amp; represents &amp;. To convert these HTML entities back to their original c
1 min read
How to Escape Ampersands in XML to Rendered as Entities ?
Extensible Markup Language(XML) is widely used for storing and exchanging structured data. It requires proper character escaping to ensure special characters like ampersands (&amp;) are correctly interpreted by XML parsers. The ampersand (&amp;) is a special character in XML used to begin entity references. To treat it as data, it must be escaped a
2 min read
What are XML Entities ?
XML is a way to organize information on the internet. It's like a recipe that tells computers how to understand and use the information. Entities in XML are like ingredients in a recipe. They help you define and reuse parts of your information, making it easier to manage and share. What is XML?XML stands for Extensible Markup Language. XML is like
8 min read
HTML | DOM HTML Object
The HTML Object property in HTML DOM is used to represent or access the HTML &lt;html&gt; element with in the object. The &lt;html&gt; element is used to return the HTML document as an Element Object. Syntax: It is used to access a &lt;html&gt; element.var x = document.getElementsByTagName("HTML")[0]; It can also be used to access a &lt;html&gt; el
3 min read
HTML | &lt;html&gt; xmlns Attribute
The HTML &lt;html&gt; xmlns Attribute is used to specify the xml namespace for a document. Important Note: This attribute is mainly required in XHTML, not valid in HTML 4.01, and optional in HTML 5. Syntax: &lt;html xmlns="http://www.w3.org/1999/xhtml"&gt; Attribute Values: https://www.geeksforgeeks.org/ It defines the namespace to use (for XHTML d
1 min read
Inline HTML Helper - HTML Helpers in ASP.NET MVC
HTML Helpers are methods that returns HTML strings. These are used in the view. In simple terms, these are C# methods that are used to return HTML. Using HTML helpers you can render a text box, an area, image tag, etc. In MVC we have many built-in HTML helpers and we can create custom helpers too. Using HTML helpers a view can show model properties
2 min read
How to return HTML or build HTML using JavaScript ?
JavaScript is very powerful and with it, we can build dynamic web content and add many features to a web application. With HTML, we create the structure of the web page and the same thing can also be done with JavaScript. There are a few JavaScript methods called as createElement(), appendChild() with which we can add nodes to the DOM tree on the f
2 min read
How to convert html.slim to html.erb ?
Introduction to slim and erb: Slim files and tools are used to make the code more light and will help to use it instead of the particular code. erb is also used to do the similar but if you want to make the changes in the code then the user should be familiar with slim/erb respectively. If you have to convert an HTML Document into html.slim file th
1 min read
three90RightbarBannerImg