HTML me Hyperlinks aur Navigation
Hyperlink ka matlab hota hai ek aisa link jo ek webpage se doosre webpage ya website ko connect karta hai. Jab aap hyperlink par click karte hain, to aap kisi dusri jagah ya page par pahunch jaate hain.
Anchor Tag (<a>)
HTML me hyperlink banane ke liye <a>
tag ka use hota hai. Iske sath href
attribute diya jata hai jisme link ki destination URL hoti hai.
Simplest Hyperlink Example:
<a href="https://www.google.com">Google</a>
Jab koi user "Google" par click karega, tab browser usko Google ki website par le jayega.
Hyperlink ke Prakar
- Absolute URL: Puri website address ke sath link, jaise
https://www.google.com
. - Relative URL: Apne website ke andar kisi dusre page ka path, jaise
about.html
yafolder/contact.html
. - Anchor Link: Ek hi page ke kisi particular section par jana, jisme
id
attribute ka use hota hai. Jaise<a href="#section1">Section 1</a>
. - Email Link: Email client ko kholne ke liye
mailto:
use hota hai. Jaise<a href="mailto:example@example.com">Email bhejein</a>
.
Example : Different Types of Links
<!-- Absolute URL -->
<a href="https://www.google.com" target="_blank">Google</a>
<!-- Relative URL -->
<a href="about.html">About Us</a>
<!-- Anchor Link -->
<a href="#section1">Jump to Section 1</a>
<!-- Email Link -->
<a href="mailto:someone@example.com">Send Email</a>
Navigation ke liye Anchor Links
Aap web pages me alag-alag sections ko id
attribute dekar anchor links bana sakte hain jise click karke user turant us section pe ja sake.
<!-- Page ke kisi section me -->
<h2 id="section1">Section 1</h2>
<!-- Link jo us section me jaye -->
<a href="#section1">Section 1 par jao</a>
Link ka Target Attribute
target
attribute specify karta hai ki link ka page kahan open hoga — current tab me ya nayi tab me. Example:
<a href="https://www.google.com" target="_blank">Google new tab me khulega</a>
Important Link Attributes
href
– link destination specify karta hai.target
– jahan link open hoga wo specify karta hai (e.g.,_blank
nayi tab ke liye).title
– link ka tooltip (extra info) dikhata hai jab mouse upar hota hai.rel
– link aur current page ke sambandh ko define karta hai, jaisenofollow
yanoopener
.
Images Ko Link Banana
Aap kisi image ko bhi hyperlink bana sakte hain. Iske liye <img>
tag ko <a>
tag ke andar rakhen:
<a href="https://www.example.com">
<img src="image.jpg" alt="Example Image" />
</a>