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
| Path | Means |
|---|---|
photo.jpg | In the same folder as this page |
images/photo.jpg | In the images folder, inside this page's folder |
../photo.jpg | In the folder one level up |
../../photo.jpg | Two levels up |
/images/photo.jpg | Starting from the root of the website |
https://site.com/photo.jpg | Absolute 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:
<img src="/img/halo-halo.svg" alt="A glass of halo-halo" width="200" height="240">
Why your picture isn't showing: a checklist
- Spelling.
classmate.jpgvsclassmates.jpg— one letter matters. - Uppercase and lowercase. On many web servers,
Photo.JPGandphoto.jpgare different files. It might work on your Windows laptop and break online. Use lowercase for all file names. - The extension. Is it really
.jpg, or is it.jpeg,.pngor.webp? Turn on file extensions in File Explorer to check. - The folder. Is the file really inside
images? Is your HTML file where you think it is? - Backslashes. Windows uses
\in folders, but the web uses/. Writeimages/logo.png, neverimages\logo.png. - Spaces in names.
my photo.jpgcan cause trouble. Rename it tomy-photo.jpg. - Paths from your own computer.
C:\Users\Juan\Desktop\photo.jpgonly 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. 🙂
By Sir Reyel · Last updated 2026-12-04