HTML HTML Basics Going Further with HTML Links and Paths Challenge

Navigate to an Id

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

2 Answers

54,333 Points

With the same page you just need to specify the id. In this case href="#portfolio".

Jamie Reardon
Jamie Reardon
Treehouse Project Reviewer

When you linking to sections of your site with an id, you should only include the # sign in your href path because the leading / is primarily used to navigation to another directory and thus taking you off the current directory entirely. Which clarifies that your link is internal to the current page, meaning that all you need to supply is the # followed by the id name:

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

Notice in my example above, you were also missing a closing ">" after your href attribute to close off the opening anchor tag. In between the opening anchor tag and closing tag you can insert text that the user will see and be able to click on to take them to that link that is placed inside the href value.

The same rules also apply for linking to files in the same directory, e.g. another page such as about.html:

<li><a href="about.html">About</a></li>