🔗
Basics

Links

<a> Tag, href, target
💡 Link ek portal hai — click karo, kahi aur pahunch jao. HTML mein <a> ("anchor") tag ye portal banata hai, href attribute batata hai portal kaha khulta hai.

<a href="url">text</a> ek clickable link banata hai. href doosri website (absolute URL, https:// se shuru), same website ka doosra page (relative path, jaise "about.html"), ya same page ka ek section (#section-id) point kar sakta hai.

target="_blank" link ko naye tab mein kholta hai — external links ke liye common hai, taaki user tumhari site se accidentally na chala jaaye.

<!-- External link: -->
<a href="https://example.com">Example Website</a>

<!-- Same site, doosra page: -->
<a href="/about.html">About Us</a>

<!-- Naye tab mein khole: -->
<a href="https://example.com" target="_blank">Naye Tab Mein Kholo</a>

<!-- Same page ke andar jump (anchor link): -->
<a href="#contact">Contact section par jao</a>
<h2 id="contact">Contact</h2>

<!-- Email link: -->
<a href="mailto:hello@example.com">Email karo</a>
🔗
Link ek portal hai — click karo, kahi aur pahunch jao. HTML mein <a> ("anchor") tag ye portal banata hai, href attribute batata hai portal kaha khulta hai.
1 / 2
⚡ Quick Recap
  • <a href="...">text</a> = clickable link
  • Absolute URL (external) ya relative path (same site)
  • target="_blank" = naya tab, #id = same-page jump
Is page mein (2 subtopics)

Absolute path poora URL hai (https://...) — kisi bhi jagah se same resource point karta hai. Relative path current file ke relative hai (./about.html, ../images/pic.jpg) — site ke andar links ke liye common, aur site ko doosre domain par move karne par bhi kaam karta rehta hai.

<!-- Absolute — poora URL: -->
<a href="https://example.com/about.html">About</a>

<!-- Relative — current location se: -->
<a href="about.html">About (same folder)</a>
<a href="../index.html">Home (ek folder upar)</a>
<a href="/contact.html">Contact (site root se)</a>
💡Tip: Same website ke andar links ke liye relative paths prefer karo — agar domain change ho (jaise staging se production), relative links automatically kaam karte rehte hain, absolute wale manually update karne padte.

download attribute link ko "click par navigate" ki jagah "click par download" bana deta hai — files (PDF, images) offer karne ke liye useful, bina naya tab khole browse karne ke.

<a href="resume.pdf" download>Resume Download Karo</a>
<a href="report.pdf" download="MyReport.pdf">Custom Naam Se Download</a>
💡Tip: download attribute sirf same-origin files ke liye reliably kaam karta hai — cross-origin (doosri website ki) files ke liye browser security restrictions ki wajah se ignore ho sakta hai.