HTML File Paths

Absolute and relative paths to files.

✍️ 3 exercises + code challenge in this lesson

A file path describes where a file (image, stylesheet, script, page) is located.

  • picture.jpg: in the same folder as the current page.
  • images/picture.jpg: in the images folder inside the current folder.
  • /images/picture.jpg: in the images folder at the root of the site.
  • ../picture.jpg: one folder up from the current folder.
  • https://example.com/picture.jpg: an absolute URL on another site.
Use relative paths for your own files. Your site will keep working when you move it to a new domain.

Key Takeaways: HTML File Paths

Mastering HTML File Paths helps you write clean and reliable HTML code. Follow standard conventions, test edge cases, and keep logic simple. Try running the code example below and complete the exercises to build confidence.

HTML File Paths Code Example

HTML
<!-- Absolute URL (works anywhere) -->
<img src="https://picsum.photos/id/1043/240/140" alt="Absolute path example" width="240" height="140">

<!-- Relative examples (these files don't exist here) -->
<!-- <img src="images/logo.png"> -->
<!-- <link rel="stylesheet" href="../css/style.css"> -->
<p>Read the comments in the code for relative path examples.</p>
Free sign-in required · Google login available

HTML File Paths Practice Exercises

Check what you learned in “HTML File Paths”.

/ 3 solved
Fill in the blank

Point to logo.png inside the images folder in the current folder.

<img src="" alt="Logo">
✓ Correct! Not quite. Try again.
Multiple choice

What does ../ mean in a file path?

✓ Correct! Not quite. Try again.
Code challenge

Add a link with the text "Up" that points to index.html one folder up.

Write the code in the live editor. Your answer is checked automatically.

Free sign-in required · Google login available

to save your exercise progress.
Finished this lesson?
Mark it complete to track your progress.

Stuck on something?

Ask the community in the CodesInTech forum.

Need a developer?

Learning on your own is great — and when you need professional help, our team builds custom software, websites and mobile apps for clients worldwide.

Explore Our Services