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! While you're at it, check out some resources Treehouse students have shared here.

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 How to Make a Website Creating HTML Content Create Navigation with Lists

im having a problem on how to link elements in an unordered list to a particular link using <href="#">

how to link elements in a list to a certain link

7 Answers

Sam Baines
Sam Baines
4,315 Points

Hi Alpha, does your code look something like this:

<header>
      <a href="index.html">
        <h1>Nick Pettit</h1>
        <h2>Designer</h2>
      </a>
     <nav>
      <ul>
        <li><a href="index.html">Portfolio</a></li>
        <li>About</li>
        <li>Contact</li>
      </ul>
     </nav>
</header>

This is the correct syntax to complete the first 2 parts of the challenge, you just need to add a few more links for the rest of the challenge, should be easy to work out from the code. Hope this helps.

TJ Egan
TJ Egan
14,420 Points
<ul>
   <li><a href="#">Home</a></li>
   <li><a href="#">About</a></li>
   <li><a href="#">Contact</a></li>
</ul>

my code is like this , and im getting errors

<nav> <ul> <li><a href="index.html">portifolio</li> </ul> </nav>

Sam Baines
Sam Baines
4,315 Points

You need a capital 'P' for portfolio and to remove the extra 'i' you have in Portfolio. And then the closing /a link anchor tag after the word portfolio.

TJ Egan
TJ Egan
14,420 Points

Don't for get to add a

</a>
Jonathan Grieve
MOD
Jonathan Grieve
Treehouse Moderator 91,253 Points

Hi Alpha,

What you want to do is put a link inside a list item, which is a "child" element of either an ordered list (<ol> or an unordered list <ul>.

So you want to try something like this

<ul>
<li>Item 1</li>
<li><a href="http://www.item2.com">Item 2</a></li>
</ul>

i have used this code still getting an error

<nav> <ul> <li><a href="index.html">Portfolio</a></li> <li><a href="about.html">About</a></li> <li><a href="contact.html">Contact</a></li> </ul> </nav>

Sam Baines
Sam Baines
4,315 Points

Did you put your UL tags inside of the NAV element tags?

yes i did that but same problem , im getting an error

<nav> <ul> <li><a href="index.html">Portfolio</a></li> <li><a href="about.html">About</a></li> <li><a href="contact.html">Contact</a></li> </ul> </nav>

Sam Baines
Sam Baines
4,315 Points

The code must look like this:

<!DOCTYPE html>
<html>
  <head>
    <meta charset="utf-8">
    <title>Nick Pettit</title>
  </head>
  <body>
    <header>
      <a href="index.html">
        <h1>Nick Pettit</h1>
        <h2>Designer</h2>
      </a>
      <nav>
        <ul>
          <li><a href="index.html">Portfolio</a></li>
          <li><a href="about.html">About</a></li>
          <li><a href="contact.html">Contact</a></li>
        </ul>
      </nav>
    </header>
    <section></section>
    <footer>
      <p>&copy; 2013 Nick Pettit.</p>
    </footer>
  </body>
</html>

I have just passed the code challenge with this exact code - check your code against it and see where your mistake is - I'm guessing it is in placement or a spelling mistake. Hope this helps.

Sam Baines you are a life saver ,, i juz noticed wr i was getting it all wrong .. thx a looot