Nishaglobal Education logo

Lists, links and images

Add bulleted and numbered lists, link pages together with relative and absolute links, and show images with useful alt text and the right file paths.

Lesson 3 of 1335 minQuiz: 4 questions

🎯 By the end of this lesson you will be able to:

  • Create bulleted, numbered and nested lists
  • Link to other pages, other websites, email addresses and parts of a page
  • Add images with alt text and correct relative paths
Outline
  1. What you'll learn and why it matters
  2. Bulleted and numbered lists
  3. Links
  4. File paths: how the browser finds your files
  5. Images
  6. Practice
  7. Common mistakes
  8. Recap
  9. Quiz
  10. Mark lesson complete

What you'll learn and why it matters

Lists, links and images are on almost every web page. Navigation menus are lists of links. Product pages are images with descriptions. Links are what make the web a *web*: they join billions of pages together. In this lesson you will also learn file paths, the number one reason images and links break for beginners.

Bulleted and numbered lists

Use <ul> (unordered list) when the order does not matter, and <ol> (ordered list) for steps or rankings. Each item goes in an <li> (list item).

HTML
<h2>Shopping list</h2>
<ul>
  <li>Rice</li>
  <li>Lentils</li>
  <li>Tomatoes</li>
</ul>

<h2>Making tea</h2>
<ol>
  <li>Boil the water.</li>
  <li>Add tea leaves and milk.</li>
  <li>Strain into a cup.</li>
</ol>

Browser preview

A list can go inside a list item to make a nested list. The inner <ul> goes inside the <li>, before its closing tag:

HTML
<ul>
  <li>Fruit
    <ul>
      <li>Mango</li>
      <li>Banana</li>
    </ul>
  </li>
  <li>Vegetables</li>
</ul>

Browser preview

A link uses the <a> element (for *anchor*). The href attribute says where it goes, and the content is the text people click.

Kind of linkExample hrefGoes to
Absolute (another website)https://www.python.org/A full web address, starting with https://
Relative (your own page)about.htmlA file in the same folder as this page
Relative, in a sub-folderrecipes/upma.htmlupma.html inside the recipes folder
Relative, up one folder../index.htmlindex.html in the folder above
Emailmailto:hello@example.comOpens the visitor's email app
Same page#opening-hoursThe element with id="opening-hours" on this page
HTML
<p>Read <a href="about.html">more about us</a>.</p>
<p>Learn Python at <a href="https://www.python.org/">python.org</a>.</p>
<p>Questions? <a href="mailto:hello@example.com">Email us</a>.</p>
<p><a href="#opening-hours">Jump to opening hours</a></p>
<h2 id="opening-hours">Opening hours</h2>
<p>Every day from 8am to 8pm.</p>

Browser preview

File paths: how the browser finds your files

Relative paths start from the folder of the page you are on. Imagine this project:

Project folder
my-website/
├── index.html
├── about.html
├── images/
│   └── cafe.svg
└── recipes/
    └── upma.html
From this pageTo reachWrite
index.htmlabout.htmlabout.html
index.htmlcafe.svgimages/cafe.svg
recipes/upma.htmlindex.html../index.html
recipes/upma.htmlcafe.svg../images/cafe.svg

../ means *go up one folder*. Always use forward slashes /, even on Windows, and match capital letters exactly: many web servers treat Cafe.svg and cafe.svg as different files.

Images

<img> is a void element: no closing tag. src is the path to the image file and alt is a short text description. Download the sample images, unzip them, and put the images folder inside your my-website folder.

⬇ Download sample images (ZIP)Three small original illustrations used in this course: cafe.svg, profile.svg and project.svg.

HTML
<h2>Our café</h2>
<img src="images/cafe.svg" alt="A cup of steaming tea on a wooden table" width="300" height="200">
<p>Come and relax with a cup of masala chai.</p>

Browser preview

AttributeWhy it matters
srcWhere the image file is. A wrong path shows a broken-image icon.
altRead aloud by screen readers, shown if the image fails, and used by search engines. Describe what matters in the image.
width and heightThe display size in pixels. Setting them stops the page jumping about while images load.

Common image formats: JPG for photos, PNG for screenshots and graphics with transparency, SVG for logos and illustrations that stay sharp at any size, and WebP for small, modern photos.

Practice

Guided exercise

A favourite places page

Make a page with a heading, a numbered list of your top three places to visit, a link to each place's tourism website (use https://example.com/ if you do not know one), and the café image with good alt text.

  1. Add an <h1> and an <ol> with three <li> items.
  2. Inside each <li>, put an <a> with an absolute href.
  3. Below the list add <img> with src="images/cafe.svg", an alt, a width and a height.
Show the solution
Solution
<h1>My top three places</h1>
<ol>
  <li><a href="https://example.com/jaipur">Jaipur</a>, for the forts and markets</li>
  <li><a href="https://example.com/kerala">Kerala</a>, for the backwaters</li>
  <li><a href="https://example.com/darjeeling">Darjeeling</a>, for the tea gardens</li>
</ol>
<img src="images/cafe.svg" alt="A cup of tea, like the ones I drank in Darjeeling" width="300" height="200">

Browser preview

How to get there: Links can sit inside list items. The image path is relative to the page, so the images folder must be next to your HTML file. The alt text says what the picture shows and why it is there.

Your turn

Fix the paths

Your page is recipes/upma.html. Write a link back to the home page index.html (one folder up) and show images/cafe.svg (also one folder up) with alt text.

Show the solution
Solution
<p><a href="../index.html">Back to the home page</a></p>
<img src="../images/cafe.svg" alt="A cup of tea on a café table" width="300" height="200">

How to get there: From inside the recipes folder, ../ goes up to my-website, then into images or straight to index.html. In the browser this works once both files are saved in the right folders.

Common mistakes

Wrong path or wrong capital letters in src

You see: A broken-image icon or the alt text instead of the image

Fix: Check the folder structure and spell the path exactly, including capitals and the file extension.

Using backslashes like images\cafe.svg

You see: Works on your Windows PC but breaks on a real website

Fix: Always use forward slashes in paths.

Leaving out https:// for another website

You see: The link goes to a missing file in your own folder

Fix: Absolute links need the full address, starting with https://.

Putting text straight inside <ul>

You see: Odd spacing, and the validator reports an error

Fix: Every item in a list must be inside an <li>.

Missing or useless alt text, like alt="image"

You see: Screen-reader users miss the meaning of the image

Fix: Describe what the image shows and why it is there, or use alt="" if it is only decoration.

Recap

  • <ul> for bullet lists, <ol> for numbered lists, with each item in <li>.
  • <a href="…"> makes a link: absolute for other sites, relative for your own files, #id for the same page.
  • Relative paths start from the current page's folder; ../ goes up one folder.
  • <img src="…" alt="…"> shows an image; alt text describes it for people who cannot see it.

Key terms

Absolute URL
A full web address, such as https://www.python.org/.
Relative path
A path to a file starting from the folder of the current page, such as images/cafe.svg.
Alt text
A text description of an image for screen readers, search engines and failed downloads.

Check your understanding

Answer all 4 questions, then check your answers to see an explanation for each one.

  1. 1. Which list should you use for step-by-step instructions?

  2. 2. Your page is in the recipes folder. Which src reaches images/cafe.svg, where images is a folder next to recipes?

  3. 3. What is the best alt text for a photo of a café's chocolate cake on its menu page?

  4. 4. Which link text is most accessible?

Answer all 4 questions to check.

Mark this lesson complete

Finished this lesson?

When you have worked through the examples and exercises, mark it complete to save your progress.