HTML Lessons

HTML Entities

HTML Entities ऐसे कोड (codes) होते हैं जो हमें Special Characters (जैसे <, >, ©, ₹, &, ") को HTML में सही तरीके से दिखाने में मदद करते हैं। क्यों? क्योंकि HTML कुछ symbols को खुद के syntax के लिए इस्तेमाल करता है। जैसे:

<p>2 < 5</p>
ऊपर वाला कोड Browser को समझ नहीं आता, क्योंकि < को वह HTML Tag की शुरुआत मानता है।
✅ सही तरीका:
<p>2 &lt; 5</p>

यहाँ &lt; एक HTML Entity है, जिसका मतलब है less than (<)।

HTML Entity का Basic Structure

हर entity इस तरह होती है
&entity_name;
या
&#entity_number;

उदाहरण:

&lt;   → <
&gt;   → >
&amp;  → &
&quot; → "
&apos; → '

Commonly Used HTML Entities (सबसे ज़्यादा इस्तेमाल होने वाले)

SymbolEntity NameDescription
<&lt;Less than
>&gt;Greater than
&&amp;Ampersand
"&quot;Double quote
'&apos;Single quote
©&copy;Copyright
®&reg;Registered trademark
&#8377;Indian Rupee symbol
&euro;Euro symbol
£&pound;Pound symbol
¥&yen;Yen symbol
&trade;Trademark symbol
°&deg;Degree symbol
½&frac12;One-half fraction
&rarr;Right arrow
&larr;Left arrow
&bull;Bullet point
&nbsp;Non-breaking space

Example: HTML Entities का प्रयोग

<!DOCTYPE html>
<html lang="hi">
<head>
  <meta charset="UTF-8">
  <title>HTML Entities Example</title>
</head>
<body>

  <h2>HTML Entities Examples</h2>

  <p>1. Less than: 2 &lt; 5</p>
  <p>2. Greater than: 10 &gt; 2</p>
  <p>3. Ampersand: AT&amp;T</p>
  <p>4. Quote: &quot;HTML सीखना आसान है&quot;</p>
  <p>5. Rupee Symbol: &#8377;500</p>
  <p>6. Copyright: &copy; 2025 CodeKeet</p>
  <p>7. Registered: &reg; Brand</p>
  <p>8. Degree Symbol: 40&deg;C</p>
  <p>9. Arrow: Learn HTML &rarr; CSS &rarr; JavaScript</p>
  <p>10. Non-breaking space: Hello&nbsp;World</p>

</body>
</html>

Browser में Output:

1. Less than: 2 < 5
2. Greater than: 10 > 2
3. Ampersand: AT&T
4. Quote: "HTML सीखना आसान है"
5. Rupee Symbol: ₹500
6. Copyright: © 2025 CodeKeet
7. Registered: ® Brand
8. Degree Symbol: 40°C
9. Arrow: Learn HTML → CSS → JavaScript
10. Non-breaking space: Hello World

Non-breaking Space (&nbsp;) क्या है?

HTML में normally extra spaces ignore हो जाते हैं। उदाहरण:

<p>Hello     World</p>
Browser में दिखेगा: Hello World लेकिन अगर आप एक fixed space चाहते हैं:
<p>Hello&nbsp;&nbsp;World</p>
Browser में दिखेगा: Hello World (दो space दिखाई देंगे)

Numeric Entities (Alternative Representation)

हर entity को आप Unicode number से भी लिख सकते हैं।

SymbolUnicodeExample
©&#169;&#169; → ©
&#8377;&#8377; → ₹
®&#174;&#174; → ®
°&#176;&#176; → °
&#8594;&#8594; → →

HTML Entities और SEO

  • Entities HTML के अंदर Special Characters को सुरक्षित रखते हैं।
  • इससे Search Engines को कोड पढ़ने में कोई गड़बड़ नहीं होती।
  • यह आपकी साइट की rendering और accessibility को बेहतर बनाता है।

HTML Entity कहाँ जरूरी होती है

  • जब <, > जैसे symbols HTML टैग से टकरा सकते हैं।
  • जब किसी legal या currency symbol की जरूरत हो।
  • जब आप quotes (") को attribute के अंदर दिखाना चाहें।
  • जब space control करना हो (&nbsp;)।

Practice Task

  • एक HTML Page बनाए जिसमें:
  • <, >, &, ", ' के लिए entities इस्तेमाल हों
  • Currency symbols ₹, €, $, £, ¥ दिखें
  • ©, ®, ™ symbols शामिल हों
  • Temperature और Arrow symbols हों
  • बीच में कुछ words के बीच fixed spaces हों

Quick Reference Table

SymbolEntityDescription
<&lt;Less than
>&gt;Greater than
&&amp;Ampersand
"&quot;Double Quote
'&apos;Single Quote
©&copy;Copyright
®&reg;Registered
&trade;Trademark
&#8377;Indian Rupee
°&deg;Degree
&rarr;Right Arrow
&larr;Left Arrow
&bull;Bullet
&nbsp;Non-breaking Space

Summary

पॉइंटमतलब
HTML Entities = Special Characters दिखाने का तरीकाजैसे <, >, &
शुरू & से और खत्म ; सेजैसे &lt;, &gt;
Non-breaking space: &nbsp;Extra space दिखाने के लिए
Unicode Code भी यूज़ कर सकते हैंजैसे &#8377;
SEO और rendering के लिए ज़रूरीकोड सुरक्षित बनाता है

HTML Entities से आप कोड को clean, readable और browser-safe रख सकते हैं। यह छोटे लगते हैं, पर असल में यह आपके webpage को error-free और professional बनाते हैं।