CHAPTER 1: EPISODE 5

Creating Links

Connecting your pages to the world wide web

The Hyperlink Highway

TrashyMcTweak

TRASHY

(in an overly dramatic tour guide voice) WELCOME, adventurers, to the HYPERLINK HIGHWAY! The most DANGEROUS and THRILLING road in all of cyberspace! Please keep your hands and feet inside the browser at all times!

CodyMcTweak

CODY

(confused) Um, we're just teaching them how to make basic links with the anchor tag...

TrashyMcTweak

TRASHY

(ignoring him completely) BEHOLD! (slaps whiteboard) The vast interconnected web of DIGITAL DESTINY! One wrong click and you could end up ANYWHERE! Cat videos! Shopping carts! THE DARK WEB! (whispers dramatically) That's where they sell illegal memes, you know.

AllyMcTweak

ALLY

(entering with coffee) That's not what the dark web is, and you know it. (to the students) Don't listen to him. Links are just a way to connect one webpage to another. They're perfectly safe.

FattyMcTweak

FATTY

(entering with a plate of link sausages) Did someone say links? I brought breakfast!

AllyMcTweak

ALLY

(sighs) Not those kinds of links, Fatty. We're teaching HTML hyperlinks. The <a> tag?

GrumpyMcTweak

GRUMPY

(stomping in with a printout) WHO'S responsible for this ABSOLUTE SECURITY NIGHTMARE?! (waves paper frantically)

GarbageMcTweak

GARBAGE

The anchor tag creates connections between documents. That's it. <a href="destination.html">Link text</a>. Where you've been, where you're going, and what you call it.

The Anchor Tag and href Attribute

Let's learn how to create links using HTML's anchor tag.

<a href="https://www.example.com">Visit Example Website</a>

Anatomy of an Anchor Tag

  • <a> - The opening anchor tag
  • href="..." - The hypertext reference (destination)
  • The text between tags - What users see and click
  • </a> - The closing anchor tag

What "href" Stands For

Hypertext REFerence

It specifies the URL or destination where the link should take the user when clicked.

GrumpyMcTweak

GRUMPY

NEVER forget to include proper link text! "Click here" tells the user NOTHING about where they're going! It's like getting into a taxi and saying "just drive" instead of giving an address!

Try It!

This is a working link: Visit Example Website

Click it to see how it opens the destination in a new tab.

Activity: Link Your Bio Page to a Favorite Website

AllyMcTweak

ALLY

Now it's time to practice! Let's add some links to the bio page you've been working on. This will make your page interactive and connected to the web.

Step-by-Step Instructions

1

Open your bio page HTML file

This is the page you created in previous lessons with your name and information.

2

Add a link to your favorite website

<p>My favorite website is <a href="https://www.example.com" target="_blank">Example Website</a>. Check it out!</p>

Replace "https://www.example.com" with the actual URL of your favorite website.

3

Add a "Back to Top" link

First, add an ID to your heading:

<h1 id="top">Your Name</h1>

Then, at the bottom of your page, add:

<p><a href="#top">Back to Top</a></p>
4

Add an email link

<p>Contact me: <a href="mailto:your.email@example.com">your.email@example.com</a></p>

Replace "your.email@example.com" with your actual email address (or a fake one for privacy).

5

Save and test your page

Open your HTML file in a web browser and test all your links:

  • Does your favorite website link open in a new tab?
  • Does the "Back to Top" link scroll back to your heading?
  • Does the email link try to open your email program?

Challenge:

Add links to at least three different websites that represent your interests or hobbies. Make sure to give each link descriptive text!

FattyMcTweak

FATTY

Remember, you're not limited to just words as link text. You can also make images clickable! Just wrap your <img> tag in an <a> tag. Just like putting cheese inside a burger instead of on top... it's all about the wrapper!

Complete Example

CodyMcTweak

CODY

Let's look at a complete example that uses all the link types we've learned about:

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>My Bio Page</title>
</head>
<body>
    <h1 id="top">Alex Johnson</h1>
    
    <img src="profile.jpg" alt="Alex Johnson profile photo">
    
    <h2 id="about">About Me</h2>
    <p>Hi! I'm Alex, a web development student. I love coding, hiking, and photography.</p>
    
    <h2 id="favorites">My Favorite Websites</h2>
    <ul>
        <li><a href="https://www.nationalgeographic.com" target="_blank" rel="noopener noreferrer">National Geographic</a> - Amazing nature photography</li>
        <li><a href="https://www.github.com" target="_blank" rel="noopener noreferrer">GitHub</a> - Where I store my code projects</li>
        <li><a href="resources.html">Coding Resources</a> - My collection of helpful tutorials</li>
    </ul>
    
    <h2 id="contact">Contact Me</h2>
    <p>Email me at <a href="mailto:alex@example.com">alex@example.com</a></p>
    
    <nav>
        <p>
            <a href="#top">Back to Top</a> |
            <a href="#about">About</a> |
            <a href="#favorites">Favorites</a> |
            <a href="#contact">Contact</a>
        </p>
    </nav>
</body>
</html>
Show more
AllyMcTweak

ALLY

This example shows different types of links:

  • External links to other websites (with target="_blank")
  • Internal links to another page (resources.html)
  • Section links within the same page (#about, #favorites, etc.)
  • A mailto: link for email
GarbageMcTweak

GARBAGE

Notice the navigation section at the bottom. This is a common pattern - creating a menu of links to different sections of the same page. As your pages get longer, this becomes increasingly important for usability.

Final Approval

TrashyMcTweak

TRASHY

AND THERE YOU HAVE IT, brave explorers! You've conquered the HYPERLINK HIGHWAY! You now possess the MYSTICAL POWER to connect pages across the vast digital universe!

GrumpyMcTweak

GRUMPY

The fundamentals look ACCEPTABLE. Just remember - with linking power comes linking responsibility! Don't create security nightmares!

SnowzieMcTweak

SNOWZIE

*enters with tail wagging, inspecting the code*

Woof! Woof! *looks at the code approvingly*

AllyMcTweak

ALLY

*excited* Snowzie approves! It looks like our lesson on hyperlinks is officially a success!

CODE IS COMMITTED!

Congratulations! You now know how to create links between webpages!

Summary

What We Learned

  • Links are created with the <a> tag
  • The href attribute specifies where the link goes
  • Absolute vs. relative URLs
  • Linking to external websites
  • Linking to sections within the same page
  • Email links with mailto:
  • Link attributes like target and rel
  • Link accessibility best practices

Next Steps

Now that you can create links, try:

  • Adding navigation to all your pages
  • Creating a multi-page website with internal links
  • Linking to resources that support your content
  • Learning how to style links with CSS
  • Creating image links (clickable images)

In the next lesson, we'll learn about creating lists to organize information!

FattyMcTweak

FATTY

Remember, links are like a good sandwich - they need a strong structure, clear contents, and they should take you somewhere worth going!