HTML Links
In this page:
- Anchor Element और Link Paths
- Absolute बनाम Relative Links
- नए Browser Tabs में Links खोलना
- Specific Page Sections से Link करना
- Local Email और Dialer Apps को Trigger करना
- rel Attribute
- Email और Phone Links
- download Attribute
- सभी Target Attribute Values समझाए गए
- Accessibility के लिए Skip Navigation Links
<a href="url" target="_blank">Link text</a>
Anchor Element और Link Paths
Links World Wide Web के रास्ते बनाते हैं। HTML में, आप a (anchor) element को href (Hypertext Reference) attribute के साथ जोड़कर hyperlinks बनाते हैं, जो user के click करने पर नेविगेट होने वाला path या web address define करता है।
उदाहरण: The Anchor Element and Link Paths
<a href="https://example.com">Visit our site</a>
Absolute बनाम Relative Links
एक absolute link पूरा, secure domain address specify करता है जो किसी protocol (जैसे, https://) से शुरू होता है। एक relative link current file location के relative आपके own server पर files को target करता है, domain prefix को छोड़ते हुए।
उदाहरण: Absolute vs. Relative Links
<a href="https://example.com/page.html">Absolute link</a>
<a href="page.html">Relative link</a>
नए Browser Tabs में Links खोलना
By default, ब्राउज़र links को उसी active window में load करते हैं। आप target="_blank" attribute का उपयोग करके links को force कर सकते हैं कि वे एक नए tab में खुलें। यह users को navigating away के दौरान आपके active tool page पर अपनी जगह खोने से बचाता है।
- अपनी site को tab-nabbing security risks से बचाने के लिए हमेशा target="_blank" को rel="noopener noreferrer" के साथ जोड़ें।
- Accepted values:
- target — _self | _blank | _parent | _top | named browsing context
- _blank के साथ rel="noopener noreferrer" की सलाह दी जाती है
उदाहरण: Opening Links in New Browser Tabs
<a href="https://example.com" target="_blank">Opens in a new tab</a>
Specific Page Sections से Link करना
अगर आपका webpage लंबा है, तो आप ऐसे links बना सकते हैं जो सीधे उसी page के specific sections पर jump करें। ऐसा करने के लिए आप अपने href link के अंदर destination element के ID attribute को target करते हैं, जो hash symbol (#) से prefixed होता है।
उदाहरण: Linking to Specific Page Sections
<a href="#section2">Jump to Section 2</a>
<h2 id="section2">Section 2</h2>
Local Email और Dialer Apps को Trigger करना
Links सिर्फ pages navigate करने से कहीं ज़्यादा कर सकते हैं।
अपने href को mailto: या tel: जैसे special protocols से prefix करके, आप user के operating system को उसका local mail application या mobile phone dialer preset contact data के साथ सीधे launch करने का निर्देश दे सकते हैं।
- आप path में query strings जोड़कर अपने mailto links के अंदर subject lines को pre-fill कर सकते हैं।
- Accepted values:
- mailto:address — mail client खोलता है; optional ?subject=, &cc=, &bcc=, &body=
- tel:+number — dialer खोलता है
- sms:number — messaging app खोलता है
उदाहरण: Triggering Local Email and Dialer Apps
<a href="mailto:[email protected]">Email us</a>
<a href="tel:+15551234567">Call us</a>
rel Attribute
rel attribute आपके page और linked page के बीच के relationship का वर्णन करता है। यह SEO और security के लिए महत्वपूर्ण है, खासकर external sites को link करते समय।
- security vulnerabilities को रोकने के लिए target=_blank उपयोग करते समय हमेशा rel=noopener जोड़ें।
- Accepted values:
- rel — noopener | noreferrer | nofollow | external | ugc | sponsored | author | bookmark | help | license | next | prev | tag
- कई tokens space-separated होते हैं
उदाहरण: The rel Attribute
<a href="https://example.com" rel="noopener">External link</a>
Email और Phone Links
HTML links सिर्फ web pages के लिए नहीं हैं। आप special URL schemes का उपयोग करके ऐसे links बना सकते हैं जो user के email app को खोलें या सीधे कोई phone number dial करें।
- Phone links खासकर mobile पर उपयोगी हैं जहां users सीधे call करने के लिए tap कर सकते हैं।
- Accepted values:
- mailto:address — mail client खोलता है; optional ?subject=, &cc=, &bcc=, &body=
- tel:+number — dialer खोलता है
- sms:number — messaging app खोलता है
उदाहरण: Email and Phone Links
<a href="mailto:[email protected]">Send email</a>
<a href="tel:+15551234567">Call now</a>
download Attribute
download attribute ब्राउज़र को किसी linked file को navigate करने या नए tab में खोलने के बजाय download करने का निर्देश देता है। आप downloaded file को server पर मौजूद original file name से अलग एक custom name भी दे सकते हैं।
- download attribute सिर्फ same-origin links के लिए reliably काम करता है — cross-origin downloads server headers के आधार पर फिर भी सिर्फ ब्राउज़र में खुल सकते हैं।
- Accepted values:
- download — boolean (कोई value नहीं) या एक suggested filename
- सिर्फ same-origin URLs, blob: और data: URLs के लिए काम करता है
उदाहरण: The download Attribute
<a href="report.pdf" download="annual-report.pdf">Download report</a>
सभी Target Attribute Values समझाए गए
target attribute नियंत्रित करता है कि कोई linked page कहां खुलता है। _blank एक नया tab खोलता है, _self (default) उसी tab में खुलता है, _parent अगर page किसी iframe के अंदर है तो parent frame में खुलता है, और _top पूरा browser window खोलने के लिए सभी frames से बाहर निकल जाता है।
- target="toolFrame" जैसे named targets कई links को एक ही specific iframe में खोलने देते हैं, जो tabbed interfaces के लिए उपयोगी है।
- Accepted values:
- _self — same browsing context (default)
- _blank — नया tab या window
- _parent — parent browsing context
- _top — top-level browsing context
- name — iframe name जैसा named browsing context
उदाहरण: All Target Attribute Values Explained
<a href="page.html" target="_blank">_blank: new tab</a>
<a href="page.html" target="_self">_self: same tab</a>
<a href="page.html" target="_parent">_parent: parent frame</a>
<a href="page.html" target="_top">_top: full window</a>
Accessibility के लिए Skip Navigation Links
एक skip link page के बिल्कुल ऊपर एक hidden link है जो keyboard से focus करने पर दिखाई देने लगता है, जिससे users पूरे navigation menu में tab किए बिना सीधे main content पर jump कर सकते हैं।
यह एक छोटा सा addition है जो keyboard और screen reader users के लिए accessibility में बहुत बड़ा अंतर लाता है।
उदाहरण: Skip Navigation Links for Accessibility
<a href="#main-content" style="position: absolute; left: -9999px;">
Skip to main content
</a>
<main id="main-content">Main content</main>
Chapter Quiz — Complete all 26 topics to unlock
0/26 topics done
Complete these topics first:
- HTML Favicon
- HTML Page Title
- HTML Tables
- HTML Lists
- HTML Block & Inline
- HTML Comments
- HTML Colors
- HTML CSS
- HTML Links
- HTML Images
- HTML RGB Colors
- HTML HEX Colors
- HTML HSL Colors
- HTML Link Colors
- HTML Link Bookmarks
- HTML Background Images
- HTML Table Borders
- HTML Table Sizes
- HTML Table Headers
- HTML Table Padding & Spacing
- HTML Colspan & Rowspan
- HTML Table Styling
- HTML Table Colgroup
- HTML Unordered Lists
- HTML Ordered Lists
- HTML Other Lists / Description Lists