HTML HTML Basics Going Further with HTML Links and Paths Challenge

Mahmoud Nabil
Mahmoud Nabil
1,495 Points

Set the "Home" link to a root-relative path that navigates to index.html

<li><a href=""> home

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

1 Answer

Nils Kriedner
Nils Kriedner
17,053 Points

The root relative link starts with a forward slash „/“

So if you want to link to index.html you use

<a href="/index.html">Link Text</a>

So the complete code here would be:

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

If you don't quite understand it yet it is perfectly well explained at around 0.40 here: https://teamtreehouse.com/library/rootrelative-paths