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
altattribute
Success criteria
- I can write a correctly structured
<a>element with anhrefattribute 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 and choose whether to open it in a new browsing context
- I can embed an image using
<img src="..." alt="...">with meaningful alt text - I can embed audio and video using
<audio>and<video>with thecontrolsattribute
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
<a> element.<a> HTML element used to create hyperlinks. The text between the tags becomes the clickable link text.<a> that specifies the destination of the link. Short for Hypertext Reference.about.html or ../images/logo.png.https://www.bbc.co.uk. It can point to the same website or a different website.target="_blank" is optional and opens the destination in a new browsing context.<img>src and alt attributes.<audio> / <video>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 and relative paths
An internal link connects to another page within the same website. A relative path describes where the destination file is relative to the current file, without including the domain name. Relative paths are the usual convention for internal links in this course, but an absolute URL can also point to a page on the same website.
Key rules for relative paths:
about.htmlβ file in the same folder as the current pagepages/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.
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 and absolute URLs
An external link connects to a different website. In this course, use an absolute URL β the full web address including the protocol (https://) and domain name β for an external link. Absolute URLs can also point to pages on the same website. The optional target="_blank" attribute opens the destination in a new browsing context, such as a new tab or window:
<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 a void element β it has no closing tag and cannot contain content. 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 asks the browser to display its standard playback controls, such as play, pause, and volume buttons:
<!-- 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's native playback controls are absent. The element or video poster may still be visible, and other playback mechanisms such as scripting or autoplay could apply. In this course, include controls when the user needs the browser's standard controls.
Void elements
Most HTML elements have an opening tag and a closing tag. A few are void elements β no closing tag exists for them, and they cannot contain content. Common void 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
| Type | When to use | Example |
|---|---|---|
| Relative path | Describing a location relative to the current file; the usual convention for internal links in this course | images/photo.jpg, ../index.html |
| Absolute URL | Giving a complete address; required for external links in this course, but can also point within the same site | https://www.bbc.co.uk |
Worked examples
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.
href="about.html".https://. Add target="_blank" to open in a new tab.<!-- 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>
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.
pages/. To get to index.html (in root), go up one level: ../index.htmlimages/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">
Embed an audio file sounds/intro.mp3 and a video file videos/demo.mp4 with controls. Explain what the alt attribute does.
<audio> with a src pointing to the MP3 file. Add controls so the play button appears.<video> with a src pointing to the MP4 file. Add controls and an optional width to size the player.<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">
Given this folder structure, write the HTML for the following two tasks:
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.
href="https://mysite.com/about.html" can still be an internal link, although relative paths are the usual convention for internal links in this course.../ 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.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="".controls when standard playback controls are required. The controls attribute asks the browser to display its native play, pause, and volume controls. Without it, those native controls are absent, although the element or poster may remain visible and scripting or autoplay could provide other playback mechanisms.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.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. In this course, use an absolute URL for an external link. Add the optional target="_blank" only when the question asks for a new tab or browsing context.
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
../images/logo.pngReasoning: 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
Example:
<a href="about.html">About us</a>External hyperlink: A link that takes the user to a different website. In this course, use an absolute URL including the protocol and domain name. The optional
target="_blank" opens it in a new browsing context.Example:
<a href="https://www.bbc.co.uk">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
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.
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).
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 is deliberately set from a subfolder β this is exactly the situation 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).