diffsnack
HTML Links Find the mistake

Links and paths

The href of a link says where it goes. It can be a full address, a path, or a special link that starts an e-mail or a phone call.

Step by step

  1. A full address like https://example.org/ can go to another website.
  2. A relative path like hybris.html looks for a file next to the current page.
  3. blog/ goes into a folder, ./ means this folder, and ../ goes up one folder (often needed in subfolders).
  4. A path that starts with /, like /img/logo.png, starts from the root of the site, whatever folder the page is in.
  5. mailto:[email protected] starts a new e-mail. Without mailto:, the browser treats the address as a page path.
  6. tel:+12025550123 asks a phone to call. The prefix is tel:, not phone:; write +, the country code, no spaces.
  7. <base href> in <head> moves where relative paths start. End it with / for a folder, or its last part is replaced.
  8. A path that starts with / still begins at the site root, so the folder in <base> does not apply to it.
The card, bug marked
1<h2>Bands &amp; Releases</h2>
2<ul>
3 <li><strong>Band A</strong>:
4 <a href="nemesis.html">Nemesis</a>,
5 <a href="hybris.htm">Hybris</a>
6 </li>
7 <li><strong>Band B</strong>:
8 <a href="faceless.html">Faceless</a>
9 </li>
10</ul>
This is how it's right
<a href="hybris.html">Hybris</a>
<a href="blog/">Blog</a>
<a href="../">Home</a>
<a href="https://example.org/">Other site</a>
<img src="/img/band-logo.png" alt="Band logo">
<a href="mailto:[email protected]">E-mail the band</a>
<a href="tel:+12025550123">Book a guitar lesson</a>

Exercises for this topic

Key rule

A path without a leading / starts from the current page's folder (or from <base>); a leading / starts from the site root.

Where you'll meet this

Every menu and every CSS or image link uses paths. One typo in a file name leads to a "not found" page. Contact pages use mailto: and tel: links.

Play this card Next article: Jump links with #id