HTML में <head> टैग निम्नलिखित एलिमेंट्स के लिए एक कंटेनर के रूप में काम करता है: <title>, <style>, <base>, <link>, <meta>, <script>, <noscript>।
HTML5 में, आप <head> एलिमेंट को शामिल किए बिना भी HTML डॉक्यूमेंट के साथ काम कर सकते हैं।
<head> के अंदर <title>
आइए अब <head> टैग को लागू करने और <title> जोड़ने का एक उदाहरण देखें:
उदाहरण
<!DOCTYPE html> <html> <head> <title>Document Title</title> </head> <body> <h2>Demo Heading</h2> <p>This is demo text.</p> <p>This is demo text.</p> <p>This is demo text.</p> <p>This is demo text.</p> </body> </html>
यह निम्नलिखित आउटपुट देगा जो <head> एलिमेंट के तहत जोड़े गए डॉक्यूमेंट के शीर्षक को प्रदर्शित करता है:

<head> के अंदर <base>
HTML में base टैग का उपयोग HTML डॉक्यूमेंट के लिए बेस URL सेट करने के लिए किया जाता है। <head> <base> एलिमेंट के लिए भी एक कंटेनर के रूप में काम करता है। उदाहरण के लिए, बेस URL https −//example.com/tutorials सभी सापेक्ष URLs जैसे /html, /java, /jquery आदि के लिए, जो अंततः हैं:
https −//example.com/tutorials/html https −//example.com/tutorials/java https −//example.com/tutorials/jquery
नोट − <base> टैग का कोई एंड टैग नहीं होता यानी इसे </base> के साथ समाप्त करने की आवश्यकता नहीं है।
निम्नलिखित एट्रिब्यूट्स हैं:
- href − यह पेज में सभी सापेक्ष URLs के लिए बेस URL सेट करता है
- target − सभी हाइपरलिंक्स और फॉर्म्स के लिए डिफ़ॉल्ट टारगेट। मान _blank, _parent, _self, _top और framename हो सकते हैं।
आइए अब <base> एलिमेंट को लागू करने का एक उदाहरण देखें:
उदाहरण
<!DOCTYPE html> <html> <head> <base href="https −//www.example.com/tutorials/"> </head> <body> <h2>Tutotials List</h2> <p><a href="java.html">Java Tutorial</a></p><p>(This will act as https −//www.example.com/tutorials/java.html)</p> <p><a href="jquery.html">jQuery Tutorial</a></p><p>(This will act as https −//www.example.com/tutorials/jquery.html)</p> <p><a href="blockchain.html">Blockchain Tutorial</a></p><p>(This will act as https −//www.example.com/tutorials/blockchain.html)</p> <p><a href="python.html">Python Tutorial</a></p><p>(This will act as https −//www.example.com/tutorials/python.html)</p> </body> </html>
आउटपुट
