Links, Images and Page Structure
Connect pages with links and relative paths, add images with useful alt text, and organize your page into header, nav, main and footer.
Welcome back!
Step 1 of 12Learn
Links connect the web
The "HT" in HTML stands for HyperText: text with links. Links are what turn separate pages into a web. You make one with the anchor element <a> and its href attribute:
<a href="https://www.w3.org/">The W3C</a>
<a href="about.html">About me</a>
<a href="#contact">Jump to contact info</a>These show three kinds of destination:
- An absolute URL includes the protocol and domain. Use it for other websites.
- A relative path like
about.htmlpoints to a file in the same folder as the current page. Use it for pages on your own site, because it keeps working when you move the whole site to a new domain. - A fragment like
#contactjumps to the element withid="contact"on the same page.
Write link text that makes sense on its own. "Click here" tells a screen reader user, who may hear a list of all the links on a page, nothing about where it leads. "Download the club schedule" does.
To open an external site in a new tab, add target="_blank". Use it sparingly: unexpected new tabs annoy many visitors.
Step 2 of 12Practice · Match the pairs
Match each href value to what it does.
Tap an answer, then tap the place where it belongs (or drag it there).
- https://example.com/news
- gallery.html
- images/cat.jpg
- ../index.html
- #faq
Step 3 of 12Learn
Paths are about folders
Relative paths confuse almost everyone at first, so picture a real folder. Suppose your site looks like this:
my-website/
index.html
about.html
images/
me.jpg
projects/
robot.htmlFrom index.html, the photo is at images/me.jpg: go into the images folder, then pick me.jpg. From projects/robot.html, the same photo is at ../images/me.jpg: first go up one level with .., then into images.
Three habits prevent most broken links:
- Lowercase everything. Your laptop may treat
Me.JPGandme.jpgas the same file, but most web servers don't. A link that works at home can break online. - No spaces in names. Use hyphens:
my-robot.html, notmy robot.html. - Never use paths from your own computer, like
C:/Users/Leo/Desktop/me.jpg. That file exists only on your machine, so every visitor sees a broken image.
Step 4 of 12Diagram
A site's folders as a tree
Tap a shape with to see more.
- my-website/
- index.html
- about.html
- images/
- projects/
- me.jpg
From index.html: images/me.jpg
- robot.html
To reach images/ from here, first go up a level with ../
Step 5 of 12Practice · Choose one
From the file projects/robot.html, which src correctly shows images/me.jpg (both folders sit inside my-website)?
Step 6 of 12Learn
Images and alt text
Images use the void element <img>, with two essential attributes:
<img src="images/robot.jpg" alt="A small wheeled robot following a black line on white paper">src says where the image file is. alt is alternative text: a description that screen readers read aloud to blind and low-vision users, that appears if the image fails to load, and that search engines use to understand the picture.
Good alt text describes what matters about the image in this context, usually in one short sentence. Skip "image of" or "picture of"; screen readers already announce that it's an image. If an image is pure decoration, like a swirly divider line, use an empty alt="" so screen readers skip it instead of reading out the file name.
Also mind the file size. A photo straight from a phone can be 4 MB or more, which makes a page slow on mobile data. Shrink photos to the size they're actually shown at, often under 1,600 pixels wide, and save them as JPEG or WebP. Use PNG or SVG for logos and drawings with sharp edges.
Finally, only use images you made yourself or have permission to use. Many sites offer free-to-use photos with clear licenses.
Step 7 of 12Practice · What would you do?
What would you do?
Ava adds a photo of her science fair volcano to her portfolio page. Which alt text is the best choice?
Step 8 of 12Compare
Alt text that helps vs alt text that doesn't
| Aspect | Weak | Useful |
|---|---|---|
| Robot photo | "image1.jpg" | "A small wheeled robot following a black line" |
| Team photo | "photo" | "Our four-person team holding the regional trophy" |
| Decorative swirl | "decoration image" | alt="" so screen readers skip it |
Step 9 of 12Learn
Semantic sections
You could build a whole page out of generic boxes called <div>, but HTML has semantic elements that say what each part of the page is for:
<header>: the top area, usually the site name or logo.<nav>: the main navigation links.<main>: the main content of this page. Use it once per page.<section>: a themed group of content, usually with its own heading.<article>: a self-contained piece, such as a blog post or a review.<footer>: the bottom area, with contact info or credits.
<body>
<header><h1>Ava's Portfolio</h1></header>
<nav><a href="index.html">Home</a> <a href="projects.html">Projects</a></nav>
<main>
<section><h2>Science</h2> ...</section>
</main>
<footer>Made by Ava, 2026</footer>
</body>They look exactly like divs until you style them, so why bother? Screen readers let users jump straight to the main content or the navigation. Search engines understand which text matters most. And when you come back to your code in three months, <nav> is far easier to read than the fifth <div> in a row.
Step 10 of 12Practice · Diagram
A page built from semantic sections
Tap the section where a copyright line usually goes.
Tap the shape that answers the question, then press Check.
- <header>
Site name or logo at the top.
- <nav>
The main menu links.
- <main>
The unique content of this page; one per page.
- <footer>
Contact links, copyright, small print.
Step 11 of 12Note
Step 12 of 12Practice · Select all that apply
Which of these choices make a page more accessible? Select all that apply.
Select all that apply.
Lesson complete!