HTML HTML Basics Images, Text and Links Understanding File Paths

Setting the Home Link in the nav to go to index.html from inside subfolder

Hi, can someone help me understand the part of the video from 3:23 to 4:21. Basically it wants us to set the Home link in the nav to navigate to index.html.

  1. Why can't I just use the code <a href="index.html">Home</a> to do this?

  2. Why do I need to go up one level, out of the current folder, and up to its parent folders. What is the reasoning behind that?I thought that to link to a file, you start from the root folder then go down, just like the code we used when we wanted the Read More link to take us to the articles page for example <a href="article/article.html>Read More</a>

  3. How come it's different rule for when linking the Home link to index.html?

Thank you.

1 Answer

Steven Parker
Steven Parker
177,563 Points
  1. You need the "../" prefix because the file you are linking to is in the parent folder of the current one.
  2. You could also use a root-relative path name by starting with "/" and list all nested folders along the way.
  3. If you're already on the home page, you don't need to reload. The "#" reference just goes to the top of the page.

Thank you!