Content · Web Development · HTML

HTML HTML Relative Paths in Nested Directories

A relative path starts from the directory containing the page that uses it. If your HTML file is inside pages/, ../ moves up one level.

1 views Published Oct 19, 2026 Updated Oct 19, 2026 Admin

A relative path starts from the directory containing the page that uses it. If your HTML file is inside pages/, ../ moves up one level.

What You Need to Know


Paths are based on where the referring file lives, not on the folder you happen to have open in your editor. Test every page after moving folders.

A relative path is resolved from the current document URL, not from the project root folder on your computer.

The goal is not to collect as many tags as possible. Pick the element that best describes what the content really is.

Example: See It in Action


Try this markup in a fresh practice file. The next section explains the parts worth paying attention to.

This is a short HTML fragment. To try it as a webpage, put it inside the body element of a complete HTML document.

project/
index.html
pages/
team.html
images/
logo.svg
<!-- From pages/team.html use ../images/logo.svg -->

Let’s Understand the Example


Follow the example from top to bottom. The indentation shows which information belongs together. Each line has a job, even when the browser does not draw it as something visible.

Look for the text “project/ index.html pages/ team.html images/ logo.svg” in the page. If the visible result surprises you, inspect the rendered elements to see what the browser actually built.

What Should You See?


The page should include “project/ index.html pages/ team.html images/ logo.svg”. If it looks different from what you expected, open developer tools and compare the source with the elements the browser created.

Try removing one piece of markup in a scratch copy, refresh the page, and compare the behavior. This is often the fastest way to understand what that piece contributes.

Try It Yourself


  1. Write a correct relative path from team.html to the logo image shown in the folder tree.
  2. Save your changes, open or refresh the page, and compare the result with the original example.
  3. Tell a friend what your change did. If you are not sure, undo it, refresh the page, and compare.

Common Beginner Mistakes


  • Writing images/logo.svg inside pages/team.html when the image is actually in the parent folder.
  • Avoid picking tags just for their default bold, italic or spaced appearance. Use CSS for presentation.

Key Takeaways


  • A relative path starts from the directory containing the page that uses it.
  • Focus on what the browser does with the markup, not just how the example looks.
  • A relative path is resolved from the current document URL, not from the project root folder on your computer.
Share this resourceSend this page to someone who may find it useful.