Chapter 5: Adding Links in HTML

What are Links?

Links (or anchor tags) in HTML allow users to click and navigate to:


🔹 Task 1: External Link

Create a link to https://www.wikipedia.org that says “Go to Wikipedia”.

🔹 Task 2: Open Link in New Tab

Create a link to https://openai.com that opens in a new tab.

The target="_blank" attribute opens the link in a new browser tab.

🔹 Task 3: Email Link

Create a link that lets users send an email to hello@example.com.

Use mailto: to open the default email app with the address pre-filled.

🔹 Task 4: Download File

Create a link to download a file named example.pdf.

The download attribute downloads the file instead of opening it.

🔹 Task 5: Anchor Link (Same Page)

Create a link that jumps to a specific section of the same page.

Use href="#id" to jump to an element with that ID.

Bottom Section

You jumped here using an anchor link!

Bonus Tip: Styling Links

You can style links using CSS like this:


a {
  color: blue;
  text-decoration: none;
}
a:hover {
  text-decoration: underline;
}