WDD  Β·  Web Design & Development

HTML: Links, Media and Addressing

Lesson 5 of 13 Approx 3 hrs (split over two periods)

Learning intentions

  • Understand how to create hyperlinks using the anchor element
  • Know the difference between relative and absolute addressing
  • Know how to create internal links (same site) and external links (other websites)
  • Know how to embed images, audio and video in a web page
  • Understand the purpose and importance of the alt attribute

Success criteria

  • I can write a correctly structured <a> element with an href attribute to create a hyperlink
  • I can write relative paths to link to pages and images within the same site
  • I can write an absolute URL to link to an external website, opening it in a new tab
  • I can embed an image using <img src="..." alt="..."> with meaningful alt text
  • I can embed audio and video using <audio> and <video> with the controls attribute
Warm up β€” what do you already know?

Answer before the lesson begins.

1. Which HTML element is used to create a hyperlink?

2. Which of the following is a relative path?

3. What is the main purpose of the alt attribute on an <img> element?

Key vocabulary

hyperlink
A clickable element that takes the user to another page or resource. Created with the <a> element.
anchor element
The <a> HTML element used to create hyperlinks. The text between the tags becomes the clickable link text.
href
The attribute inside <a> that specifies the destination of the link. Short for Hypertext Reference.
relative path
A file path that is relative to the current page's location. Does not include a domain name. E.g. about.html or ../images/logo.png.
absolute URL
A complete web address including the protocol and domain. E.g. https://www.bbc.co.uk. Used for linking to other websites.
internal link
A hyperlink that points to another page within the same website. Uses a relative path.
external link
A hyperlink that points to a different website. Uses an absolute URL and usually opens in a new tab with target="_blank".
<img>
The image element β€” embeds an image in the page. Self-closing (no closing tag needed). Requires src and alt attributes.
alt attribute
Alternative text for an image. Read aloud by screen readers and shown if the image fails to load. Essential for accessibility.
<audio> / <video>
Elements that embed audio and video players. The controls attribute adds play/pause/volume controls for the user.

HTML: Links, Media and Addressing

The anchor element β€” creating hyperlinks

A hyperlink is a clickable element that takes users to another location β€” another page on the same site, or a completely different website. In HTML, hyperlinks are created with the anchor element <a>:

<a href="about.html">About us</a>

The href attribute (Hypertext Reference) holds the destination. The text between the opening and closing tags is the visible, clickable link text β€” it should describe where the link goes.

Internal links β€” relative paths

An internal link connects to another page within the same website. It uses a relative path β€” a path that describes where the destination file is relative to the current file. You do not need to include the domain name.

Key rules for relative paths:

  • about.html β€” file in the same folder as the current page
  • pages/contact.html β€” file in a subfolder called pages
  • ../index.html β€” go up one level (to the parent folder), then find index.html
  • ../images/logo.png β€” go up one level, then into the images folder

The ../ sequence means "go up one folder level". Use one ../ for each level you need to climb.

root/ index.html pages/ about.html ← You are here images/ logo.png Link to home page: ../index.html ↑ ../ = go up one level then index.html in root Link to logo image: ../images/logo.png ↑ ../ = go up images/ = enter images folder logo.png = the file

From pages/about.html, use ../ to go up one level before navigating to other folders

<!-- Internal link to a page in the same folder -->
<a href="about.html">About us</a>

<!-- Internal link from a subfolder page back to the home page -->
<a href="../index.html">Home</a>

External links β€” absolute URLs

An external link connects to a different website entirely. It uses an absolute URL β€” the full web address including the protocol (https://) and domain name. External links should almost always open in a new browser tab, using the target="_blank" attribute so users do not leave your site:

<a href="https://www.bbc.co.uk" target="_blank">Visit BBC News</a>

The image element

The <img> element embeds an image. Unlike most elements, it is self-closing β€” it has no closing tag. It requires two key attributes:

  • src β€” the path to the image file (relative or absolute)
  • alt β€” alternative text describing the image
<img src="images/logo.png" alt="School logo">

The alt attribute is essential for accessibility. Screen readers β€” used by visually impaired people β€” read the alt text aloud so the user understands what the image shows. If the image fails to load (e.g. the file path is wrong), the alt text is displayed in its place. Always write meaningful, descriptive alt text.

Audio and video elements

The <audio> and <video> elements embed media players. The controls attribute adds the play, pause, and volume buttons the user needs to operate the player:

<!-- Audio player -->
<audio src="sounds/intro.mp3" controls></audio>

<!-- Video player with width set -->
<video src="videos/demo.mp4" controls width="640"></video>

Without controls, the browser embeds the media but gives the user no way to play it β€” always include it.

Self-closing tags

Most HTML elements have an opening tag and a closing tag. A few elements are self-closing β€” they have no separate closing tag because they cannot contain any content. Common self-closing elements include:

  • <img> β€” image
  • <br> β€” line break
  • <meta> β€” metadata in the head

Writing <img></img> is not correct HTML5 β€” simply use <img> on its own.

Relative vs absolute β€” summary

TypeWhen to useExample
Relative pathLinking to pages/images within your own siteimages/photo.jpg, ../index.html
Absolute URLLinking to a different websitehttps://www.bbc.co.uk

Worked examples

Example 1 β€” Internal and external links

Write HTML to create (a) a link from index.html to about.html (both in the same root folder), and (b) a link to https://www.bbc.co.uk that opens in a new tab.

1
For the internal link, use a relative path β€” both files are in the same folder, so just use the filename: href="about.html".
2
For the external link, use the full absolute URL with https://. Add target="_blank" to open in a new tab.
3
Write descriptive link text β€” not "click here", but text that tells users where the link goes.
<!-- Internal link β€” same folder -->
<a href="about.html">About this site</a>

<!-- External link β€” opens in new tab -->
<a href="https://www.bbc.co.uk" target="_blank">Visit BBC News</a>
Example 2 β€” Relative paths with a folder structure

Given this folder structure, write the correct src for the image and href for the link from pages/about.html to both index.html and images/logo.png.

root/ β”œβ”€β”€ index.html β”œβ”€β”€ pages/ β”‚ └── about.html ← you are here └── images/ └── logo.png
1
You are in pages/. To get to index.html (in root), go up one level: ../index.html
2
To get to images/logo.png (also in root), go up one level then into images: ../images/logo.png
<!-- From pages/about.html -->
<a href="../index.html">Home</a>
<img src="../images/logo.png" alt="Site logo">
Example 3 β€” Embedding audio, video and explaining alt text

Embed an audio file sounds/intro.mp3 and a video file videos/demo.mp4 with controls. Explain what the alt attribute does.

1
Use <audio> with a src pointing to the MP3 file. Add controls so the play button appears.
2
Use <video> with a src pointing to the MP4 file. Add controls and an optional width to size the player.
3
Alt text on <img> is read aloud by screen reader software used by visually impaired people β€” without it, they cannot know what the image shows.
<audio src="sounds/intro.mp3" controls></audio>

<video src="videos/demo.mp4" controls width="640"></video>

<!-- Alt text example -->
<img src="images/chart.png" alt="Bar chart showing sales by month">
Now you try

Given this folder structure, write the HTML for the following two tasks:

root/ β”œβ”€β”€ index.html β”œβ”€β”€ pages/ β”‚ └── gallery.html ← you are here └── images/ └── photo.jpg

Task A: Write an <a> tag from gallery.html to index.html using a relative path.

Task B: Write an <img> tag to display photo.jpg, with suitable alt text. Use the correct relative path from gallery.html.

<!-- Task A: relative link from pages/gallery.html to index.html -->
<a href="../index.html">Back to home</a>

<!-- Task B: image from pages/gallery.html to images/photo.jpg -->
<img src="../images/photo.jpg" alt="Gallery photograph">

In both cases, ../ is needed because you are in the pages/ subfolder and need to go up one level before navigating into the correct location.

Common mistakes
βœ•
Using an absolute URL for an internal link. Writing href="https://mysite.com/about.html" instead of href="about.html" makes your site fragile β€” if the domain changes, all links break. Use relative paths for links within your own site.
βœ•
Missing the ../ when linking out of a subfolder. If your page is in pages/ and you write href="index.html", the browser looks for pages/index.html β€” which doesn't exist. You need href="../index.html" to go up one level first.
βœ•
Omitting the alt attribute on images. An <img> without alt is inaccessible β€” screen readers have nothing to read. Always include alt text. If the image is purely decorative, use an empty alt: alt="".
βœ•
Forgetting controls on audio and video. Without the controls attribute, the media element is embedded but invisible β€” users cannot play, pause, or adjust volume. Always add controls to <audio> and <video>.
βœ•
Writing target="blank" instead of target="_blank". The underscore is required. Without it, the browser opens the link in a tab literally named "blank" rather than opening a new tab.
Exam tip

Relative paths are the most-tested topic in WDD. When the exam gives you a folder diagram, always identify which folder the current page is in. Count how many levels up you need to go (one ../ per level). Then navigate down to the target file. Check: does your path start from the current file's location, not from the website's root?

The exam commonly asks: "Write the HTML to display the image" or "Write an anchor element to link to the home page". Always include both required attributes β€” for images: src and alt. For links: href. External links also need target="_blank".

Task Set

Questions 1–4 are auto-checked. Questions 5–10 are self-marked β€” write your answer, then reveal the model answer to check your work.

1. What does the target="_blank" attribute do on an anchor element? TYPE 1

2. Which of the following is a relative path? TYPE 1

3. Why is the alt attribute on <img> important for accessibility? TYPE 1

4. Which of the following is the correct HTML to embed an image? TYPE 1

5. A website has this folder structure. Write the relative path needed in pages/about.html to link to images/logo.png. (2 marks) TYPE 2

root/ β”œβ”€β”€ index.html β”œβ”€β”€ pages/ β”‚ └── about.html ← you are here └── images/ └── logo.png
Answer: ../images/logo.png

Reasoning: You are in pages/. You need to go up one level (../) to reach the root folder, then navigate into images/ and select logo.png.

In a full img tag: <img src="../images/logo.png" alt="Site logo">

6. Explain the difference between an internal hyperlink and an external hyperlink. Give an example of each. (4 marks) TYPE 2

Internal hyperlink: A link that takes the user to another page within the same website. Uses a relative path β€” no domain name is needed.
Example: <a href="about.html">About us</a>

External hyperlink: A link that takes the user to a completely different website. Uses an absolute URL including the protocol and domain name. Should open in a new tab using target="_blank".
Example: <a href="https://www.bbc.co.uk" target="_blank">BBC News</a>

Marks: internal defined (1), internal example (1), external defined (1), external example (1).

7. Add a <nav> element to the HTML skeleton below, containing links to three pages: Home (index.html), Gallery (gallery.html), and Contact (contact.html). All pages are in the same folder. (3 marks) TYPE 2

<header>
  <h1>My Website</h1>
  <!-- Add your nav here -->
</header>
<header>
  <h1>My Website</h1>
  <nav>
    <a href="index.html">Home</a>
    <a href="gallery.html">Gallery</a>
    <a href="contact.html">Contact</a>
  </nav>
</header>
Marks: nav element used (1), correct relative paths (1), all three links present (1). Accept links in a ul/li list structure.

8. Write the HTML to embed an audio player for sounds/welcome.mp3 and an image of a microphone from images/mic.jpg with appropriate alt text. (3 marks) TYPE 2

<audio src="sounds/welcome.mp3" controls></audio>
<img src="images/mic.jpg" alt="Photograph of a microphone">
Marks: correct audio element with src and controls (1), correct img element with src (1), meaningful alt text (1).

9. Explain why alt text is important for web accessibility. State two reasons. (2 marks) TYPE 2

Any two of the following (1 mark each):

1. Screen reader software reads the alt text aloud, so visually impaired users can understand what the image shows.
2. If an image fails to load (e.g. due to a broken file path or slow connection), the alt text is displayed in place of the image, so users still receive the information.
3. Search engines read alt text when indexing images, which improves a website's discoverability.

10. Write a complete HTML fragment (not a full page β€” just the body content) that contains: a level-2 heading "Recommended Links"; a paragraph of text; an image from images/banner.jpg with alt text; one internal link to news.html; and one external link to https://www.sqa.org.uk opening in a new tab. (5 marks) TYPE 2

<h2>Recommended Links</h2>
<p>Here are some useful resources for your studies.</p>
<img src="images/banner.jpg" alt="Website banner image">
<a href="news.html">Latest news</a>
<a href="https://www.sqa.org.uk" target="_blank">SQA website</a>
Marks: heading (1), img with src and alt (1), internal link with relative path (1), external link with absolute URL (1), target="_blank" on external link (1).
Teacher notes β€” Shift+T to hide

Suggested timing: This lesson spans two periods. Period 1 (1hr): warm-up, vocab, notes on links and paths (stop before audio/video). Period 2 (2hr): recap paths, cover audio/video, now you try, task set. Do not rush the folder diagram β€” it is where most misconceptions sit.

Key misconception β€” relative paths: Draw the folder tree on the board and have pupils trace the path with their finger: "I am here. I need to go here. How many levels up?" One ../ per level up. Q5 and Q10 are deliberately set from a subfolder β€” these are exactly the situations pupils fail in assessments.

Live demo: Create a simple two-page site in Notepad/VS Code on the projector. Show a working relative link, then break it by removing the ../ and demonstrate the 404 error. Then fix it. This makes the rule concrete.

SQA command words: "Write the HTML" (correct element, correct attribute names, correct attribute values, correct syntax), "Explain" (requires a reason, not just a definition), "Give an example" (must be a written example, not a description).