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 HTML Basics Getting Started with HTML Lists and Links Challenge

Will Wacaser
Will Wacaser
2,354 Points

Error message telling me to set the href to "pies.html" which I already did

Someone tell me I am tripping.

index.html
<!DOCTYPE html>
<html>
  <head>
    <title>Lists and Links</title>
  </head>
  <body>
    <ul>
      <a href="cakes.html"><li>Cakes</li></a>
      <a href="pies.html"><li>Pies</li></a>
      <a href="candy.html"><li>Candy</li></a>
    </ul>
  </body>
</html>

You need to put the <a> tags inside the <li> tags.

For example...

<li><a href="cakes.html">Cakes</a></li>

Let me know if that helps.

3 Answers

Matthew Long
Matthew Long
28,407 Points

The keyword for this challenge is "inside". It is expecting the anchor tags to be inside the list item tags:

<!DOCTYPE html>
<html>
  <head>
    <title>Lists and Links</title>
  </head>
  <body>
    <ul>
      <li><a href="cakes.html">Cakes</a></li>
      <li><a href="pies.html">Pies</a></li>
      <li><a href="candy.html">Candy</a></li>
    </ul>
  </body>
</html>
Will Wacaser
Will Wacaser
2,354 Points

Thanks man! Will that always be the case?

Matthew Long
Matthew Long
28,407 Points

For this case you should have the list item be the direct child of the unordered list tag (same with ordered lists). Which means the anchor tag should be nested inside the list item tag.

There are other cases where it's much more acceptable to wrap the anchor tag on the outside. Such as when you want multiple elements to be the link.

Jason Anders
Jason Anders
Treehouse Moderator 145,860 Points

Hi Will,

Yes, when it comes to links inside of lists, this will always be the case, as the <li> tag is the only tag that can be a child of a list element.

:) :dizzy:

To the best of my knowledge, yes.