<!DOCTYPE html>
<html>
<head>
<title>Proper Nesting Example</title>
</head>
<body>
<h1>Welcome to My Website</h1>
<p>
This is a <b><i>simple and clean</i></b> example of
<u>nested HTML tags</u>.
</p>
<p>
<a href="https://example.com">
<strong>Click here to visit our website.
</a>
</p>
</body>
</html>
Rules of Nesting in Hindi
Rules of Nesting:
HTML में Nesting का मतलब होता है एक tag को दूसरे tag के अंदर रखना। Nesting करते समय कुछ जरूरी rules होते हैं जिन्हें follow करना बहुत जरूरी है।
सबसे पहला rule यह है कि जब आप किसी tag को खोलते हो, तो उसे उसी order में बंद करना होता है। इसे proper closing order कहते हैं। Example के लिए अगर आपने <b> tag को <i> के पहले खोला है, तो <i> tag को पहले बंद करना होगा।
गलत nesting से browser को confusion हो सकता है और web page का layout बिगड़ सकता है। इसलिए हमेशा ध्यान रखना चाहिए कि tags ठीक से open और close हों।
HTML में कुछ tags self-closing होते हैं, जैसे <img> या <br>. इन्हें extra closing tag की जरूरत नहीं होती। इन tags को nested नहीं करना चाहिए।
Nested tags को सही indent करना भी एक अच्छी practice होती है। इससे code साफ दिखता है और समझना आसान होता है कि कौन सा tag कहां खत्म हो रहा है।
Example के लिए सही nesting ऐसे होती है:
<b><i>This is bold and italic text.</i></b>
यहां <i> tag <b> के अंदर ठीक से बंद हुआ है।
अगर nesting गलत होगी, जैसे:
<b><i>This is wrong nesting.</b></i>
तो यह invalid मानी जाएगी और browser इसे सही से render नहीं करेगा।
कभी भी overlapping tags नहीं बनाने चाहिए। मतलब ऐसा structure न हो जिसमें एक tag आधा अंदर और आधा बाहर बंद हो।
Proper nesting से HTML का structure मजबूत और browser friendly बनता है। इससे SEO और accessibility में भी फायदा होता है।
Example
इस example में
- <b> और <i> सही ढंग से एक-दूसरे के अंदर nested हैं।
- <a> tag के अंदर भी <strong> और <em> सही से बंद हुए हैं।
- Structure बिलकुल साफ है, कोई tag बाहर से पहले बंद नहीं हुआ।
Request
अगर आपको यह article useful या interesting लगा हो, तो please इसे अपने dosto aur family ke साथ जरूर share करें। आपका एक छोटा सा कदम हमें और अच्छा content बनाने के लिए motivate करता है। Thank you!
ध्यान दें कि इस page पर आपको कुछ ads भी देखने को मिल सकते हैं। इसके लिए हम आपसे माफी चाहते हैं हम इस content को तैयार करने में काफी मेहनत और time लगाते हैं, ताकि आपको valuable जानकारी मिल सके। इन्हीं ads की मदद से हम ये काम continue कर पाते हैं।
आपके support और understanding के लिए दिल से धन्यवाद।