Aral Code

Links & Media Lesson 17 of 42

HTML File Paths — Linking to Files in Other Folders

Understand relative and absolute file paths in HTML, how to point to files in subfolders and parent folders with ../, and fix broken images and links.

"Sir, bakit hindi lumalabas yung picture ko?" This is probably the most common question in any web design class. In almost every case, the answer is a wrong file path. This lesson will help you understand paths once and for all, so your images and links always work.

What is a file path?

A file path is the "address" of a file, telling the browser where to find it. You use paths in href (links), src (images, audio, video), and when linking CSS files.

Think of it like giving directions to your house. You can give the complete address ("Purok 2, Brgy. San Jose, Tarlac City"), or directions from where the person is now ("from the plaza, turn left, then the second house"). Web paths work the same way.

Our sample project folder

We'll use this folder structure for every example in this lesson:

my-website/
├── index.html
├── about.html
├── images/
│   ├── logo.png
│   └── classmates.jpg
└── blog/
    ├── first-post.html
    └── photos/
        └── field-trip.jpg

Case 1: file in the same folder

From index.html, to link to about.html (they're in the same folder), just write the file name:

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

Case 2: file inside a subfolder

From index.html, the logo is inside the images folder. Write the folder name, a forward slash, then the file name:

<img src="images/logo.png" alt="Our logo">

Going deeper works the same way, one folder at a time:

<!-- From index.html -->
<img src="blog/photos/field-trip.jpg" alt="Field trip to Intramuros">

Case 3: file in the parent folder (going up)

Now we're in blog/first-post.html and want to show images/logo.png. The images folder isn't inside blog — it's one level up. Use ../ to mean "go up one folder":

<!-- From blog/first-post.html -->
<img src="../images/logo.png" alt="Our logo">
<a href="../index.html">Back to Home</a>

../ can be repeated to go up more levels: ../../ goes up two folders.

Case 4: starting from the root with /

A path starting with / begins at the root (the top folder) of the website, no matter where the current page is:

<img src="/images/logo.png" alt="Our logo">

This works the same from any page, which is convenient. The catch: it only works when the site is running on a web server. If you open your file by double-clicking it on your computer, / points to the root of your whole hard drive, and the image won't load.

Quick reference

PathMeans
photo.jpgIn the same folder as this page
images/photo.jpgIn the images folder, inside this page's folder
../photo.jpgIn the folder one level up
../../photo.jpgTwo levels up
/images/photo.jpgStarting from the root of the website
https://site.com/photo.jpgAbsolute URL on another website

Try it

This website has an images folder at its root, so the root path works in the practice editor. Try changing the file names to mango.svg, jeepney.svg or halo-halo.svg:

Example A root-relative image path
<img src="/img/halo-halo.svg" alt="A glass of halo-halo" width="200" height="240">

Why your picture isn't showing: a checklist

  1. Spelling. classmate.jpg vs classmates.jpg — one letter matters.
  2. Uppercase and lowercase. On many web servers, Photo.JPG and photo.jpg are different files. It might work on your Windows laptop and break online. Use lowercase for all file names.
  3. The extension. Is it really .jpg, or is it .jpeg, .png or .webp? Turn on file extensions in File Explorer to check.
  4. The folder. Is the file really inside images? Is your HTML file where you think it is?
  5. Backslashes. Windows uses \ in folders, but the web uses /. Write images/logo.png, never images\logo.png.
  6. Spaces in names. my photo.jpg can cause trouble. Rename it to my-photo.jpg.
  7. Paths from your own computer. C:\Users\Juan\Desktop\photo.jpg only works on Juan's computer. Copy the image into your project folder and use a relative path.

Quick Quiz

Check what you learned. Walang grade ito, practice lang. 🙂

1. From index.html, how do you show images/logo.png?
2. What does ../ mean?
3. From blog/first-post.html, which path reaches index.html in the main folder?
4. Your image works on your laptop but not online. What is a likely cause?

By Sir Reyel · Last updated 2026-12-04