HTML Entities

HTML Entities क्या होते हैं?

HTML Entities special codes होते हैं जिनका उपयोग उन characters को दिखाने के लिए किया जाता है जो HTML में reserved होते हैं या keyboard से आसानी से type नहीं हो पाते।
Browser entities को पढ़कर सही symbol या character display करता है।

HTML Entities की ज़रूरत क्यों पड़ती है?

कुछ characters HTML में पहले से ही किसी काम के लिए use होते हैं।
अगर उन्हें direct लिख दिया जाए तो browser उन्हें code समझ लेता है।

उदाहरण के लिए < और > tags बनाने के लिए use होते हैं, इसलिए इन्हें text के रूप में दिखाने के लिए entity की ज़रूरत होती है।

HTML Entity का Basic Syntax

HTML Entity दो तरह से लिखी जा सकती है।

Name based:

&entityName;

Number based:

&#entityNumber;

Reserved Characters के लिए HTML Entities

ये characters HTML में direct use नहीं किए जाते।

&lt;   <!-- < -->
&gt;   <!-- > -->
&amp;  <!-- & -->
&quot; <!-- " -->
&apos; <!-- ' -->

Example:

<p>&lt;p&gt; is an HTML tag</p>

Output:

<p> is an HTML tag

Space के लिए HTML Entities

HTML में multiple spaces ignore हो जाते हैं, इसलिए special space entities use की जाती हैं।

&nbsp;   <!-- Non-breaking space -->
&ensp;   <!-- En space -->
&emsp;   <!-- Em space -->

Example:

<p>Hello&nbsp;&nbsp;World</p>

Currency Symbols के लिए HTML Entities

&dollar;  <!-- $ -->
&euro;    <!-- € -->
&pound;   <!-- £ -->
&yen;     <!-- ¥ -->
&#8377;   <!-- ₹ -->

Example:

<p>Price: &#8377;500</p>

Mathematical Symbols के लिए HTML Entities

&plus;    <!-- + -->
&minus;   <!-- − -->
&times;   <!-- × -->
&divide;  <!-- ÷ -->
&equals;  <!-- = -->

Example:

<p>10 &times; 5 = 50</p>

Arrow Symbols के लिए HTML Entities

&rarr;  <!-- → -->
&larr;  <!-- ← -->
&uarr;  <!-- ↑ -->
&darr;  <!-- ↓ -->

Example:

<p>Next Page &rarr;</p>

Copyright और Trademark Symbols

&copy;   <!-- © -->
&reg;    <!-- ® -->
&trade;  <!-- ™ -->

Example:

<p>&copy; 2025 MyWebsite</p>

Emoji और Special Symbols के लिए Entities

Emoji usually number-based entities से लिखे जाते हैं।

&#128512;  <!-- 😀 -->
&#128525;  <!-- 😍 -->
&#128640;  <!-- 🚀 -->

Example:

<p>Welcome &#128512;</p>

HTML Entities और UTF-8 Encoding

HTML file में UTF-8 charset होना ज़रूरी है, ताकि entities सही तरीके से render हों।

<meta charset="UTF-8">

Entity Name vs Entity Number

Entity name याद रखना आसान होता है, लेकिन सभी symbols के लिए name available नहीं होते।
Entity number हर symbol के लिए available होता है और ज्यादा reliable माना जाता है।

Example:

&copy;
&#169;

दोनों का output same होता है।

HTML Entities Summary

HTML Entities special characters दिखाने के लिए use होते हैं
Reserved characters के लिए entities ज़रूरी हैं
Spaces, symbols, currency और emoji के लिए entities काम आती हैं
UTF-8 encoding best practice है

Share your love