HTML HTML Basics Going Further with HTML Links and Paths Challenge

Assistance with question

The question is telling to set a link for "portfolio" to a navigating like. How can I do it?

index.html
<!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</a></li>
    </ul>
    <h1 id="portfolio">My Portfolio</h1>
  </body>
</html>

1 Answer

Nils Kriedner
Nils Kriedner
17,053 Points

You link to an id by using the hash tag „#“ followed by the id-name.

Like this:

<a href=“#id-name“>Link-Text</a>

So in your example it would look like this:

<a href=“#portfolio“>Portfolio</a>

One little thing that is not wrong but that you should be aware of is indentation. The second list item in your code should better be on the same indentation as the first list item.

So this is correct indentation:

<ul>
  <li>list-item 1</li>
  <li>list-item 2</li>
</ul>

And this is not so good:

<ul>
  <li>list-item 1</li>
    <li>list-item 2</li>
</ul>
<a href=“#portfolio“>Portfolio</a>

It will still work, there is no problem for the browser. But anybody looking at your code might get confused because it looks like there is another list within a list (which is possible but is not the case here).