Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community!

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

HTML HTML Basics Going Further with HTML Links and Paths Challenge

Andrew Poteau
Andrew Poteau
2,819 Points

root relative links

In this code, we are asked to provide a root relative link to the part of the page with the id of "portfolio". I guess I don't understand root relative links, because I can't think of anything besides the path that I put in the code below, but it keeps saying it's the wrong answer.

<!DOCTYPE html> <html> <head> <title>Portfolio Page</title> </head> <body> <img src="../img/logo.png" alt="Site logo"> <ul> <li><a href="/">Home</a></li> <li><a href="/#portfolio">Portfolio</a></li>
</ul> <h1 id="portfolio">My Portfolio</h1> </body> </html>

<!DOCTYPE html> 
    <title>Portfolio Page</title>
    <img src="../img/logo.png" alt="Site logo">
      <li><a href="/">Home</a></li>
      <li><a href="/index.html/#portfolio">Portfolio</a></li>                
    <h1 id="portfolio">My Portfolio</h1>

2 Answers

Dane Parchment
Dane Parchment
Treehouse Moderator 11,074 Points

If you are trying to make links to you index.html and the id tag, then you are going about it wrong.

Currently you are linking them as though they are routes on your url, but that isn't what you are trying to accomplish, instead you need to link the paths that contain the file.

For your home link since you are just connecting to your index.html, then all you need to do is:

<li><a href="index.html">Home</a></li>

and for your id based links, you just need to specify the id, you only need to include relative pathing if it is for a link that is not in the current file.

<li><a href="#portfolio">Portfolio</a></li>   

Hopefully that helps, if you need more assistance understanding something let me know.

Andrew Poteau
Andrew Poteau
2,819 Points

Dane, thanks for taking the time. Actually, for the Home link, "/" was the correct answer. The question specifically asked for a root relative link, not a full relative path. For the Portfolio link, one of the reasons I was stuck is that I didn't notice that the current page was the Portfolio page. But I still want to make sure I understand root relative linking correctly. Assuming we are on a web server and not a personal computer, if you use the root symbol "/", you can follow it with any page or id anywhere on the site, no matter how many subdirectories you're removed from it?