Loading

T1 HTML · Lesson 3

Text, links and images

Links to other sites, other pages and other parts of a page; paths between files; email and phone links; images with alt text and captions; and video and audio.

  • make links to other sites and other pages, and open one in a new tab safely
  • write relative and absolute paths, and say which file each one reaches
  • link to a part of the same page, and to an email address or a phone number
  • put an image on a page with an alt text that serves people who cannot see it
  • add video and audio with controls, and a message for browsers that cannot play them
About 60 minutesChecked against Node.js on the laptop (the kit runs every code block with it) 22.23.1 (2026-10-26)Play this lesson's games

The back cover

The web is a web because of links. One click takes a reader from a page to another page, another site, or another part of the same page. Pictures, videos and sounds come in the same way: a short element names a file, and the browser fetches it.

These pages show how a link is written, and how one file finds another with a path. They show how a link can jump within a page, start an email or dial a phone.

Then come pictures, with the alt text that describes them to anyone who cannot see them, and video and audio with the browser's own buttons.

Before you start

The story: To the fish market

A traveller stops you in the Print Quarter, lost and cross. "Your friend's panel told me the ferry office was this way," she says. "It sent me to a fish market."

It is Corin's panel, his first one on a real tower. Its passage-markers, the lines you tap to go to another panel, point to the wrong places. Its pictures show as empty squares, and Wren, of the Lantern Society, says her listening-glass hears only "picture, picture, picture", with no idea what any of them show.

Corin rubs his neck. "They worked on my desk," he says.

Lesson 2 built a page of text. Now the page reaches out: links to other pages and to other parts of itself, pictures, and sound and video. Each of these is an element with an attribute that says where something is. It builds on these ideas; each has a tiny example.

What you already knowA tiny exampleWhere it comes back
The parts of a URL.https:, the host, the path /tech/atlas/, the fragment #rows.A link's address is a URL, whole or in part.
The fragment never reaches the server.#rows tells the browser where to scroll.Links that jump to a part of the same page use it.
Elements and attributes.<p lang="hi">: a name and a quoted value in the opening tag.href and src are attributes holding addresses.
id names one element.<h2 id="offers">.A link can jump straight to it.
Empty elements.<br> has no content and no closing tag.An image is an empty element too.
Folders hold files./home/asha/shop/bill.js, from lesson 2 of Learning to learn.A website is a folder of files that point at one another.
Directions are relative or absolute."The shop next door" depends on where you stand; "Shop 4, MG Road, Pune" does not.Paths in links are relative or absolute in the same way.
A caption describes a photo.A newspaper photo with a line under it saying who and where.alt text describes an image to people who cannot see it.
Status codes.404 Not Found when nothing is at an address.A broken link or a missing picture is a 404 in the Network tab.

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

  • make links to other sites and other pages, and open one in a new tab safely;
  • write relative and absolute paths, and say which file each one reaches;
  • link to a part of the same page, and to an email address or a phone number;
  • put an image on a page with an alt text that serves people who cannot see it;
  • add video and audio with controls, and a message for browsers that cannot play them.

In one line

This lesson connects a page to everything else: you need lesson 1's URLs and fragments, and lesson 2's elements, attributes and ids.

Paths: how one file finds another

At a glance

A full URL, with https: and the site's name, works from anywhere, and it is the only kind that reaches other sites. Within one's own site, shorter paths work. A relative path is worked out from the folder of the page it is written in: a name goes into a folder, and two dots go up to the folder above.

A path that starts with a slash starts at the site's top folder, its root, whichever page it is written in. So the same relative path, written in two pages in different folders, can reach two different files.

Take a guess: The link about.html sits in two pages in different folders: does it reach the same file from both?

Give directions to a friend standing outside your house, and you can say "the shop two doors down". Give directions to someone in another city, and you must say "Shop 4, MG Road, Pune". The first kind depends on where the listener stands; the second works from anywhere. Links and pictures use both kinds of address, and the difference matters.

A website is a folder of files. Here is a small one, for a shop:

The folder of a small site

shop/
  index.html          the home page
  about.html          the About page
  products/
    rice.html         a product page
  images/
    logo.svg          the shop's logo
Kind of pathExampleRead it asWorks from
full URL (absolute)https://shop.example.com/about.htmlthis exact address on the webanywhere, any site
relativeabout.htmlthe file called about.html, in the same folder as this pagedepends on where this page is
relative, into a folderproducts/rice.htmlgo into products, then rice.htmldepends on where this page is
relative, up a folder../index.htmlgo up one folder (two dots), then index.htmldepends on where this page is
root-relative/images/logo.svgfrom the top folder of this site, into images, then logo.svgany page of this site

Two dots, .., always mean "the folder above". A path starting with a slash starts at the site's top folder, its root, whichever page it is written in.

The same path, from two pages

A relative path is worked out from the page it is written in. So the same text can reach different files. The checks below use the URL value of lesson 1 to work out exactly which file each link reaches.

<!-- written in index.html, at the top of the site -->
<a href="products/rice.html">Basmati rice</a>
<a href="about.html">About us</a>

Checked in Chrome

  • from index.html, it reaches /products/rice.html
  • from index.html, it reaches /about.html
<!-- written in products/rice.html, one folder down -->
<a href="../index.html">Home</a>
<a href="/images/logo.svg">Our logo</a>

Checked in Chrome

  • from products/rice.html, it reaches /index.html
  • from products/rice.html, it reaches /images/logo.svg

From rice.html, which is inside products, ../index.html goes up out of products to reach the home page. The root-relative /images/logo.svg reaches the logo from any page, because it always starts at the top.

Which path to use

For pages and pictures of your own site, use relative or root-relative paths: the site then works on your laptop and online alike. For other sites, use the full URL with https://.

Worked example 2

On the page products/rice.html, a link to about.html should go to the About page at the top of the site. A developer wrote href="about.html". Which file does it reach, and what is the fix?

What we have: a relative path written one folder down

What we need: the file it reaches, and a path that reaches /about.html

The plan: work it out from where the page is: products/

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

Checked in Chrome

  • from products/rice.html, it reaches /products/about.html
  • From products/rice.html, about.html means "about.html in this folder", which is products/about.html. There is no such file: the visitor gets a 404.
  • <a href="../about.html">About us</a>

    Checked in Chrome

    • from products/rice.html, it reaches /about.html

    It reached /products/about.html, which does not exist; ../about.html (or /about.html) reaches the real page.

    Check: the check works the path out from the page's own folder, which is exactly what the browser does.

    When you are stuck: paths

    Ask first: which folder is the page that contains this path in?

    Read the path from there: a name goes into this folder, .. goes up, a leading / starts at the top.

    A broken path shows as a 404 in the Network tab of DevTools, with the address the browser tried.

    Your turn

    From index.html at the top of the site, which file does images/logo.svg reach?Tap to reveal
    1. Into the images folder, then logo.svg.

    /images/logo.svg.

    What do two dots, .., mean in a path?Tap to reveal
    1. They move you between folders.

    The folder above.

    Why use a relative path for your own pages rather than a full URL?Tap to reveal
    1. Think of the site on your laptop and online.

    Because the site then works in both places without changing every link.

    Did you know?

    Paths borrowed from Unix

    The paths in web addresses were not invented for the web. Tim Berners-Lee wrote that slashes were the clear choice for separating the parts of a hierarchy, and that the relative URI syntax is just unix pathname syntax reused without apology. So a slash between folders, and two dots for the folder above, came straight from the way Unix names its files.

    Why it fits here: The relative paths of this topic follow the same rules as file paths in a Unix terminal, which the Linux steps of this school use.

    Source: Tim Berners-Lee: Answers for Young People and FAQ

    Cool URIs don't change

    In 1998 Tim Berners-Lee wrote a short page with a firm title: Cool URIs don't change. His point was that addresses do not break by themselves: people change them, by moving and renaming files. The cost is real. A 2024 study by the Pew Research Center found that 38% of web pages that existed in 2013 were no longer accessible a decade later.

    Why it fits here: A path is a promise to everyone who links to it. Moving a file breaks every path that pointed at it.

    Sources: W3C: Cool URIs don't change (Tim Berners-Lee); Pew Research Center: When Online Content Disappears

    In one line

    A full URL works from anywhere; a relative path is worked out from the page's own folder (a name goes in, .. goes up), and a path starting with / starts at the site's root.

    Jumping within a page, and links that call or write

    At a glance

    A link can jump to a part of the same page. Give the target element an id, and write the link's href as # followed by that id; the browser scrolls there. On another page, the id goes after the page's name and a #, as in page.html#prices.

    A link's address need not be a web page at all. With mailto: in front of an email address, a click opens the email app, ready to write. With tel: in front of a number written in full, such as +919876543210, a phone dials it.

    Take a guess: Why is a phone number in a link written with +91 and no spaces?

    A thick textbook has a contents page: "Chapter 4 . . . page 62". You do not read pages 1 to 61 to get there; you turn straight to 62. A long web page can have a contents list of the same kind, whose links jump straight to a part of the same page.

    Linking to a part of the page

    Give the part an id, as in lesson 2. Then link to it with a fragment, the # part of a URL from lesson 1: href="#prices" means "this page, scrolled to the element whose id is prices". The fragment never travels to the server; the browser does the scrolling itself.

    <p><a href="#timings">Timings</a> | <a href="#prices">Prices</a></p>
    <h2 id="timings">Timings</h2>
    <p>Open 8 am to 9 pm, every day but Sunday.</p>
    <h2 id="prices">Prices</h2>
    <p>Chai 15, samosa 20.</p>

    Checked in Chrome

    • every link's target exists on the page
    • the first link jumps to timings

    Each link's href is a # followed by an id. The check confirms that both ids exist; a link to #price, missing its s, would jump nowhere, silently.

    You can also jump to a part of another page: href="about.html#team" opens about.html scrolled to its element with the id team.

    A common mistake

    Writing the # in the id itself, as id="#prices". The # belongs only in the link: id="prices" and href="#prices".

    Email and phone links

    A link's address does not have to be a web page. With the scheme mailto:, clicking the link opens the visitor's email app with the address filled in. With tel:, a phone dials the number. Both are just schemes at the start of the href, like https: in lesson 1.

    <p>Questions? Email <a href="mailto:hello@ashastores.example">hello@ashastores.example</a>
    or call <a href="tel:+919876543210">98765 43210</a>.</p>

    Checked in Chrome

    • the first link writes an email
    • the second link calls
    • the number is written in full, with +91

    The phone number in the href is written in full international form, with +91 and no spaces, so that it dials correctly from anywhere. The link text can show it the friendly way, with a space. The address hello@ashastores.example uses the ending .example, kept for examples, so it reaches nobody.

    Worked example 3

    Write a contents list for a results portal page with three sections, Class 9, Class 10 and Class 11, each with a link that jumps to its section heading.

    What we have: three sections that need ids, and three links to them

    What we need: headings with ids, and links with matching fragments

    The plan: give each h2 an id without spaces; link to each with # and the same id

    <p><a href="#class-9">Class 9</a> | <a href="#class-10">Class 10</a> | <a href="#class-11">Class 11</a></p>
    <h2 id="class-9">Class 9</h2>
    <h2 id="class-10">Class 10</h2>
    <h2 id="class-11">Class 11</h2>

    Checked in Chrome

    • every link's target exists
    • three headings with ids

    Three h2s with the ids class-9, class-10 and class-11, and three links to #class-9, #class-10 and #class-11.

    Check: every href, without its #, is the id of a heading, which is what the check tests.

    When you are stuck: jumping links

    Find the id the link should reach, and check it is spelt exactly the same, capitals included.

    The # goes only in the href, never in the id.

    For a phone number, write the href in full: tel:+91 and the ten digits, no spaces.

    Your turn

    Write the link that jumps to the element with the id offers.Tap to reveal
    1. A # and the id.

    <a href="#offers">Offers</a>.

    Which scheme makes a link open the visitor's email app?Tap to reveal
    1. It goes at the start of the href.

    mailto:.

    Why write a phone link's href as tel:+919876543210 rather than tel:98765 43210?Tap to reveal
    1. Think of a visitor dialling from another country, and of the space.

    So that it dials correctly from anywhere: the country code is included and there are no spaces.

    Did you know?

    mailto is as old as the URL standard

    The mailto: scheme is not a later add-on. RFC 1738, the specification of Uniform Resource Locators published in December 1994 by Tim Berners-Lee, Larry Masinter and Mark McCahill, already lists it among its schemes: mailto, for an electronic mail address, beside http, ftp, gopher, news and telnet. A link that writes an email is as old as that standard.

    Why it fits here: The mailto: and tel: links of this topic are schemes like https:, and mailto: was one of the earliest.

    Source: RFC 1738: Uniform Resource Locators (URL)

    In one line

    href="#id" jumps to the element with that id on the same page (page.html#id on another); mailto: writes an email and tel: dials a number written in full, such as tel:+919876543210.

    Images: img and alt

    At a glance

    An img element shows a picture. It is a void element, with no closing tag. Its src attribute, short for source, holds the path to the picture, and its alt attribute describes the picture in words. Screen readers read the alt text aloud, browsers show it when the picture fails to load, and search engines read it too.

    A picture that is pure decoration gets an empty alt, so that it is skipped. Width and height keep the picture's space ready, so the page does not jump while it loads. The figure element with figcaption pairs a picture with its caption.

    Take a guess: If a photo fails to load on a slow connection, what does the visitor see in its place?

    A newspaper prints a photo with a line of small print below it: "Farmers at the Nashik onion market". If the photo comes out smudged, the line still tells you what it showed. A web page shows pictures the same way. The page itself holds no picture: it holds the picture's address, and a few words that describe it, in case the picture cannot be seen.

    Image

    An img element. Its src attribute (short for source) holds the address of the picture file; its alt attribute (short for alternative text) describes the picture in words.

    A picture on a real site

    <img src="images/rice.jpg" alt="A 5 kg bag of basmati rice" width="300" height="200">

    Read it piece by piece. src="images/rice.jpg" is a path, exactly like a link's href in the last section: the browser fetches the file from there. alt is the description. width and height give its size in pixels, the tiny dots a screen is made of.

    Notice that img has no closing tag. It has no content to wrap: the picture comes from the file, not from text between tags. It is an empty element, also called a void element, like br in lesson 2.

    Seeing a picture load

    The block above names a file that lives on a real shop's site, so it cannot load here. To see a picture load in this lesson, the next block uses a data URI. That is an address that holds the picture itself, written out as text, instead of saying where a file is. The picture here is a small drawing written in SVG, a format for drawings that the CSS step meets again. You do not need to read the drawing's code yet; look at the img element around it.

    <img src="data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' width='120' height='80'><rect width='120' height='80' fill='gold'/><circle cx='60' cy='40' r='25' fill='tomato'/></svg>" alt="A red circle on a yellow card" width="120" height="80">

    Checked in Chrome

    • the picture loaded: it is 120 pixels wide
    • it has its description
    • its height is given: 80

    The check asks the browser for the picture's natural width, the width of the file it fetched: 120. A picture that failed to load has a natural width of 0, which is how a script finds broken pictures.

    Why alt matters

    Alt text is read in three situations. A person who is blind uses a screen reader, which reads the page aloud and says the alt text where the picture is. A visitor on a slow train connection may see the alt text while the picture fails to load. And a search engine reads it to learn what the picture shows.

    PicturePoor altGood alt
    a product photo of a pressure cookeralt="image1"alt="A 5 litre steel pressure cooker"
    the shop's logo used as a link to the home pagealt="logo"alt="Asha Stores home"
    a chart of monthly salesalt="chart"alt="Sales rose from 40 to 65 thousand rupees, April to June"

    Write alt as you would describe the picture to a friend on the phone: what it shows that matters on this page. Leave out "picture of": the screen reader already says it is a picture.

    Decorative pictures: an empty alt

    Some pictures carry no meaning: a thin line between sections, a pattern behind a heading. Describing them would only waste a listener's time. For these, write the alt attribute with nothing in it, alt="". That tells a screen reader "skip this one".

    <p>Today's offers</p>
    <img src="data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' width='200' height='10'><rect y='4' width='200' height='2' fill='gray'/></svg>" alt="" width="200" height="10">
    <p>Rice is 10% off.</p>

    Checked in Chrome

    • the alt attribute is there
    • and it is empty: a screen reader skips the line

    A common mistake

    Leaving alt out entirely is not the same as an empty alt. With no alt at all, many screen readers read out the file's name instead, such as "divider underscore line dot svg". Every img gets an alt: a description, or empty for decoration.

    Width and height: keeping the page still

    A picture's file can take a moment to arrive. If the page does not know its size, it first draws the text with no gap, then shoves everything down when the picture lands. You have seen this: you go to tap a link and it jumps away. Writing width and height lets the browser keep a space of the right size ready from the start.

    A picture with a caption: figure and figcaption

    For a picture with a caption shown under it, like the newspaper photo, wrap both in a figure element, with the caption in a figcaption. The two then belong together, for the browser and for screen readers.

    <figure>
      <img src="data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' width='120' height='80'><rect width='120' height='80' fill='gold'/><circle cx='60' cy='40' r='25' fill='tomato'/></svg>" alt="A red circle on a yellow card" width="120" height="80">
      <figcaption>The logo of the Sunrise Chai Stall, Pune.</figcaption>
    </figure>

    Checked in Chrome

    • the picture is inside the figure, and loaded
    • the caption is inside the figure too

    Alt and the caption do different jobs. Alt replaces the picture for someone who cannot see it. The caption is shown to everyone, and adds something the picture alone does not say: here, whose logo it is.

    Worked example 4

    A school site shows a photo of its science lab, from the file photos/lab.jpg, 400 by 250 pixels. Write the img so that it is described for a screen reader and the page does not jump while it loads.

    What we have: the file's path and its size

    What we need: an img with src, alt, width and height

    The plan: src takes the path; alt describes what matters; width and height take the size in pixels

    <img src="photos/lab.jpg" alt="Students at the benches of the school science lab" width="400" height="250">
    1. The src is the relative path photos/lab.jpg, worked out from the page's folder as in the last section.
    2. The alt says what the photo shows that matters here: students, and the lab.
    3. The width 400 and height 250 let the browser keep a space ready, so nothing jumps.

    An img with src="photos/lab.jpg", an alt that describes the lab, width="400" and height="250".

    Check: read the alt aloud with your eyes closed: it should tell you what the picture shows.

    Worked example 5

    A shop's page has a small arrow picture before every item of a list, only for looks. One developer wrote no alt; another wrote alt="arrow". What should it be, and why?

    What we have: a picture used only for decoration

    What we need: the right alt for it

    The plan: ask: does the picture add meaning? If not, it should be skipped

    1. The arrow adds no meaning: the list reads the same without it.
    2. With no alt, a screen reader may read the file name before every item.
    3. With alt="arrow", it says "arrow" before every item, which only gets in the way.

    An empty alt, alt="": the screen reader then skips every arrow.

    Check: the decorative block above has the same shape, and its check confirms the alt is present but empty.

    A path that fails: Leaving the alt out "because the picture means nothing": the screen reader then reads the file name instead of skipping it.

    When you are stuck: images

    A picture that does not show is almost always a wrong path: work the src out from the page's folder, as in the paths section.

    Check the file name's spelling and its ending exactly: rice.JPG and rice.jpg are different files on most servers.

    For alt, ask: if I could not see this picture, what would I need to be told?

    Your turn

    Why does img have no closing tag?Tap to reveal
    1. What would go between the tags?

    Because it has no content: the picture comes from the file named in src. It is a void element.

    Write the alt for a thin decorative line between two sections.Tap to reveal
    1. It carries no meaning.

    alt="", an empty alt, so that a screen reader skips it.

    What do width and height on an img prevent?Tap to reveal
    1. Think of what happens when a picture arrives late.

    They stop the page jumping when the picture arrives: the browser keeps the space ready.

    Did you know?

    The day the web got pictures

    On 25 February 1993 Marc Andreessen, at the NCSA where the Mosaic browser was being made, wrote to the web's mailing list: I'd like to propose a new, optional HTML tag: IMG. Its one required argument, SRC, named an image file for the browser to fetch over the network and show in the text. Less than three weeks later, Mosaic 0.10 introduced the IMG tag.

    Why it fits here: The img element of this topic, with its src attribute, has kept the shape of that first proposal.

    Sources: www-talk archive: proposed new tag: IMG (Marc Andreessen); Wikipedia: Mosaic (web browser)

    Half the top sites miss alt text

    Each year WebAIM tests the home pages of the top one million websites for accessibility errors. In its 2026 report, 53.1% of home pages had images with missing alternative text. Only low-contrast text was more common, at 83.9%. The report adds that the most common kinds of error have stayed the same for the last seven years.

    Why it fits here: Writing the alt text of this topic fixes one of the most common faults on the whole web.

    Source: WebAIM: The WebAIM Million, the 2026 report

    In one line

    An img is a void element: src holds the picture's path and alt describes it (empty for pure decoration). Width and height keep its space ready, and figure with figcaption pairs a picture with its caption.

    Video and audio

    At a glance

    The video and audio elements put a player on the page. The controls attribute gives the player the browser's own buttons: play, pause, volume and the rest. Inside, each source element names a file and its type, such as video/mp4, and the browser plays the first one it can.

    Text placed inside the element is the fallback, shown only by a browser that cannot play the file. The preload attribute set to none tells the browser to download nothing until the visitor presses play, which saves the visitor's data.

    Take a guess: Should a video start playing by itself, with sound, the moment a page opens?

    A television in a shop window with no buttons is a poster: you can look at it, but not pause it or turn the sound down. Videos and sounds on a page need buttons too. HTML gives them with one attribute.

    Video and audio

    The video element shows a video on the page and the audio element plays a sound. The attribute controls asks the browser to draw its own buttons: play, pause, a time bar and the volume.

    <video controls width="320" height="180" preload="none">
      <source src="videos/recipe.mp4" type="video/mp4">
      Your browser cannot play this video. <a href="videos/recipe.mp4">Download it</a> instead.
    </video>

    Checked in Chrome

    • the browser draws its play and pause buttons
    • the file is said to be an MP4 video
    • a message for browsers that cannot play it
    • nothing is downloaded until play is pressed

    Take it line by line.

    • controls is an attribute with no value: writing the word alone switches it on, like a light switch. Without it, the video shows no buttons at all.
    • The source element names the file in src, and its kind in type. The type, video/mp4, lets the browser skip a file it cannot play without downloading it first. Like img, source is a void element.
    • The text inside video, after the source, is the fallback: it shows only in a browser that cannot play video at all. A download link there means nobody is left with nothing.
    • preload="none" tells the browser to download nothing until the visitor presses play. On a phone with a small data pack, that saves the visitor's data for a video they may never watch.

    The file videos/recipe.mp4 is a placeholder here, a path on a real site, so pressing play in this block finds no video. The checks above test the element itself, which is what this section teaches.

    Two files, one video

    Video files come in a few kinds. MP4 plays in every modern browser; WebM is often smaller. You can list both: the browser reads the source elements from the top and plays the first one it can.

    <video controls width="320" height="180" preload="none">
      <source src="videos/recipe.webm" type="video/webm">
      <source src="videos/recipe.mp4" type="video/mp4">
      Your browser cannot play this video.
    </video>

    Checked in Chrome

    • two files to choose from
    • the smaller WebM is tried first

    Audio

    Audio works the same way, with an audio element. It has no picture, so it needs no width or height: the browser draws only the buttons.

    <audio controls preload="none">
      <source src="sounds/bhajan.mp3" type="audio/mpeg">
      Your browser cannot play this sound.
    </audio>

    Checked in Chrome

    • play and pause buttons
    • audio/mpeg is the type for an MP3 file

    A common mistake

    Writing autoplay so that a video starts by itself. Most browsers refuse to autoplay a video with sound, because visitors find it rude, so the video stays still and the page looks broken. Leave the starting to the visitor, with controls.

    AttributeOnWhat it does
    controlsvideo, audiothe browser's own play, pause, time and volume buttons
    src and typesourcethe file's path, and its kind (video/mp4, video/webm, audio/mpeg)
    preload="none"video, audiodownload nothing until play is pressed
    width and heightvideoits size in pixels, so the page keeps the space ready
    the text insidevideo, audiothe fallback, shown only where the element cannot play

    Worked example 6

    A cooking site wants its 2 minute dal recipe video, the file media/dal.mp4, on the page at 480 by 270 pixels. It needs buttons, no download until the visitor asks, and a download link for old browsers.

    What we have: the file, the size and three wishes: buttons, no early download, a fallback

    What we need: a video element with the right attributes and children

    The plan: controls for the buttons; preload="none"; a source with src and type; the fallback text with a link

    <video controls width="480" height="270" preload="none">
      <source src="media/dal.mp4" type="video/mp4">
      <a href="media/dal.mp4">Download the dal recipe video</a>.
    </video>

    Checked in Chrome

    • buttons, and no early download
    • 480 pixels wide
    • the fallback links to the same file
  • Each wish became one attribute or one child: controls, preload, the source, the fallback link.
  • The fallback link's text names what it downloads, as the links section asked.
  • A video with controls, width 480, height 270 and preload="none"; a source for media/dal.mp4 of type video/mp4; and a download link inside.

    Check: the checks confirm each wish on the element the browser built.

    When you are stuck: video and audio

    No buttons? Add the controls attribute.

    No sound or picture? Check the src path as in the paths section, and that the type matches the file's kind.

    A blank page in an old browser? Put fallback text, ideally a download link, inside the element.

    Your turn

    Which attribute gives a video its play and pause buttons?Tap to reveal
    1. One word, with no value.

    controls.

    When is the text inside a video element shown?Tap to reveal
    1. Think of a browser that cannot play video.

    Only in a browser that cannot play the video: it is the fallback.

    Why write preload="none" on a long video?Tap to reveal
    1. Think of a visitor on a small data pack.

    So that nothing is downloaded until the visitor presses play, which saves their data.

    Did you know?

    The end of Flash

    For years, video on the web usually played through a plugin, Adobe Flash; HTML video was not as widespread as Flash videos. The video element made the browser itself the player. In January 2015 YouTube switched to HTML video instead of Flash by default. Adobe ended support for Flash on 31 December 2020.

    Why it fits here: The controls of this topic come from the browser itself, which is why no plugin is needed any more.

    Sources: Wikipedia: HTML video; Adobe: Flash Player end of life

    Why sound does not start by itself

    Chrome has an autoplay policy. Muted autoplay is always allowed, but autoplay with sound is allowed only in some cases, for example when the user has already interacted with the site by a click or a tap. Otherwise, the browser does not start the sound. The policy is meant to give the visitor more control of what plays.

    Why it fits here: The controls of this topic leave the decision to the visitor, which is what the browsers now insist on.

    Source: Chrome for Developers: Autoplay policy in Chrome

    In one line

    video and audio get the browser's own buttons from controls. Each source names a file and its type, and the browser plays the first it can. The text inside is the fallback, and preload="none" saves the visitor's data.

    Where it is used

    Links, pictures and media are what make the web feel like one place rather than a pile of separate pages.

    What you learnedWhere it is usedA real example
    linksevery menu, every search result, every "Read more"a news site's home page is mostly links, each a headline that names its article
    a new tab, with rel="noopener"links that leave the sitea college's page opens the university's results site in a new tab, so its own page stays open
    relative and root-relative pathsevery link and picture inside one sitea shop's 400 product pages all load the same /images/logo.svg
    jumping to an idcontents lists of long pages, links shared to one partan encyclopedia article's contents list jumps to each section
    mailto: and tel:contact pages, "Call now" buttons on phonesa clinic's page with a Call link that dials its reception at a tap
    img and altevery product photo, every logoa shopping site's photos all carry alt text, read aloud to blind shoppers
    figure and figcaptionphotos with captions, charts, code samplesa newspaper's online article: the photo, and the line under it
    video and audio with preload="none"online classes, recipes, podcastsa coaching site's lecture videos, downloaded only when a student presses play

    Mistakes and debugging

    As in lesson 2, the browser shows no error for any of these: a broken link only goes nowhere, a missing picture only leaves a gap. Here are the common slips, and how to find each.

    1. A link that is never closed

    <p>See <a href="prices.html">the price list. Open till 9.</p>
    <p>Call us any time.</p>

    Checked in Chrome

    • (the slip: the browser carries the unclosed link on into the next paragraph)

    The a element was never closed. Its link runs to the end of the first paragraph, and the browser even carries it into the second: Call us any time is a link to prices.html too. The fix: <a href="prices.html">the price list</a>. When more of the page turns into a link than you meant, look for an a that opened and never closed.

    2. A relative path worked out from the wrong folder

    A link written in products/rice.html as href="about.html" looks for products/about.html, as the paths section showed. The fix: ../about.html or the root-relative /about.html. To find it, open DevTools' Network tab: the broken request shows as 404, with the full address the browser tried.

    3. A path written the Windows way

    Windows writes folders with backslashes, as in images\logo.svg. Web addresses always use forward slashes: images/logo.svg. A backslash may work on your own laptop and break on the real server. The same goes for spaces in file names: name files like dal-recipe.mp4, with hyphens.

    4. Capitals that do not match

    Most web servers treat Logo.svg and logo.svg as two different files. A path that works on a laptop, where the two are often the same, breaks once the site is online. The fix: name every file in small letters, and write paths in small letters.

    5. An id written with its #

    <p><a href="#offers">See the offers</a></p>
    <h2 id="#offers">Offers</h2>

    Checked in Chrome

    • (the slip: no element is called offers, so the link jumps nowhere)

    The id here is "#offers", with the # in it, so nothing is called offers. The fix: id="offers".

    6. An img with no alt

    <img src="data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' width='120' height='80'><rect width='120' height='80' fill='gold'/><circle cx='60' cy='40' r='25' fill='tomato'/></svg>" width="120" height="80">

    Checked in Chrome

    • (the slip: no alt, so a screen reader has nothing to say, or reads the address)

    The picture shows, so the slip is invisible to anyone who can see it. The fix: an alt that describes it, or alt="" if it is pure decoration.

    The debugging corner: the Network tab

    Open DevTools (F12) and its Network tab, then reload the page. Every file the page asked for is listed: each picture, video and page. A missing one shows its status, 404, in red, with the exact address the browser tried. Comparing that address with where the file really is finds most path slips at once; the DevTools step teaches the tab in full.

    Quick card

    The lesson on one card.

    Every element of the lesson

    <p><a href="#visit">How to visit</a></p>
    <p>Our suppliers are on <a href="https://www.enam.gov.in/" target="_blank" rel="noopener">the eNAM site</a>.</p>
    <figure>
      <img src="data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' width='120' height='80'><rect width='120' height='80' fill='gold'/><circle cx='60' cy='40' r='25' fill='tomato'/></svg>" alt="A red circle on a yellow card" width="120" height="80">
      <figcaption>The Sunrise Chai Stall logo.</figcaption>
    </figure>
    <video controls width="320" height="180" preload="none">
      <source src="videos/stall.mp4" type="video/mp4">
      <a href="videos/stall.mp4">Download the video</a>.
    </video>
    <h2 id="visit">How to visit</h2>
    <p><a href="../index.html">Home</a> | <a href="mailto:chai@sunrise.example">Email</a> | <a href="tel:+919876543210">Call</a></p>

    Checked in Chrome

    • the jump link reaches the heading
    • the new tab is opened safely
    • the picture loaded, with its description
    • the video has buttons and a typed source
    • an email link and a phone link
    Element or attributeWhat it is
    <a href="...">a link; its text names where it goes
    target="_blank" rel="noopener"open in a new tab, safely
    about.html, ../about.html, /about.htmlin this folder; one folder up; from the site's root
    href="#id"jump to the element with that id
    mailto:, tel:write an email; dial a number (in full, with +91)
    <img src alt width height>a picture: its path, its description, its size; a void element
    alt=""a decorative picture, skipped by screen readers
    <figure>, <figcaption>a picture with its caption
    <video controls>, <audio controls>media with the browser's own buttons
    <source src type>one file for the media, and its kind
    preload="none"download nothing until play is pressed

    The story: Where the ferry is

    You go through Corin's panel with him, marker by marker. One address left out the way up from its folder, so it went one floor too deep. Another jumped to a part of the panel that had a different name. You work out each path from the panel's own place, and fix them.

    Then the pictures. Each one gets a line of words saying what it shows, and the empty square becomes "a map of the harbour, with the ferry office marked". Wren listens and nods. "Now I know where the ferry is too," she says.

    Reagents gathered: href, relative path, fragment, alt, void element.

    Sources