Chapter 1.4☕ 10 min read

Links

Auto stand se destination tak — ek click mein pahuncho.

01What are Links?

You are at Lakdi-ka-pool auto stand. You tell the auto driver: "Bhai, Hitech City chalo." He takes you from one place to another. That's exactly what an HTML link does.

The <a> tag (anchor tag) creates a clickable link. User clicks it — browser takes them from current page to another page. Just like the auto takes you from Lakdi-ka-pool to Hitech City.

🛺
Auto Analogy: The href attribute is like telling the auto driver the destination. No href = no destination = auto won't move. Link without href is useless.
02The Anchor Tag — Anatomy

The <a> tag creates clickable links. Here's the anatomy:

  • <a> — The auto itself. This is the clickable element.
  • href — The destination. "Hitech City" = the URL you want to go to.
  • target="_blank" — New window. Like taking a second auto instead of the same one.
  • Text between tags — What user sees. "Click here" or "Go to Hitech City" — the display text.
<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8">
    <title>Hyderabad Places to Visit</title>
  </head>
  <body>
    <h1>Hyderabad Places to Visit</h1>

    <h2>Historical Places</h2>
    <p>
      <a href="https://en.wikipedia.org/wiki/Charminar" target="_blank">
        Charminar — Read on Wikipedia ↗
      </a>
    </p>
    <p>Iconic 400-year-old monument with 4 minarets. Heart of old Hyderabad.</p>

    <p>
      <a href="golconda-fort.html">Golconda Fort — Full Guide →</a>
    </p>
    <p>Magnificent fort with acoustic system and light show at night.</p>

    <h2>Lakes & Parks</h2>
    <p>
      <a href="hussain-sagar.html">Hussain Sagar — Visit Guide →</a>
    </p>
    <p>Heart-shaped lake with Buddha statue. Boat rides available.</p>
  </body>
</html>
<a href="...">Opening tag with destination URL
href="https://..."Absolute URL — external website
href="about.html"Relative URL — local file in same folder
href="/contact"Relative URL — from root of website
target="_blank"Opens in new tab — like a new auto
</a>Closing tag — clickable area ends here
04How Links Work — Flow
1
User sees linkClickable text with underline on the page
2
User clicks itBrowser reads the href destination
3
Browser navigatesNew page loads — user reaches destination

Pro tip: Always use descriptive link text. "Click here" is bad. "Visit Paradise Biryani Menu" is good. Google reads your link text to understand the page.

05Exercise — Hyderabad Directions Page

Build a page with links to popular Hyderabad places — like a local directions guide.

1

Open VS Code. Create a new file — name it hyderabad-places.html

2

Use the starter code below and add your links:

<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8">
    <title>Hyderabad Places to Visit</title>
  </head>
  <body>
    <!-- h1: Page title -->
    <!-- h2: Categories -->
    <!-- a href: Links to places -->
    <!-- p: Descriptions -->

  </body>
</html>

Complete these:

💡
Common mistake: Forgetting http:// in external links. href="google.com" treats it as a local file. Use href="https://google.com" for external sites.

Done — Key Points:

  • <a> tag creates clickable links
  • href = destination URL — without it, link does nothing
  • target="_blank" opens link in new tab
  • ✅ Absolute URLs = full address (https://...)
  • ✅ Relative URLs = local files (about.html, /contact)
  • ✅ Use descriptive text — never "click here"
Course Search
Search across all chapters & stages
📖

Search the course

Type any topic — branching, stash, rebase, hooks — and jump straight to that chapter.

merge branchesgit stashundo commitrebase