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

setting the href attribute

I can't see what I'm doing wrong, why does it keep saying I need to set the href to attribute to pies.html, I thought I had?

index.html
<!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>

2 Answers

Jennifer Nordell
seal-mask
STAFF
.a{fill-rule:evenodd;}techdegree
Jennifer Nordell
Treehouse Teacher

Hi there! There are a couple of things going on here. First, you've changed the text "Cakes" to "cakes" and "Pies" to "pies". These are the pieces of text that your users will click on to go to the links.

But above and beyond that, on every line, you've started your anchor tag or <a> element but forgotten the closed angle bracket >. Because of this error, it cannot make it past the first link. Take a look:

<!-- You typed -->
 <li> <a href="cakes.html"cakes</a></li>

<!-- But you meant to type -->
 <li> <a href="cakes.html">cakes</a></li>

This is true for every line that contains a link.

Hope this helps! :sparkles:

Jamie Shankland
Jamie Shankland
798 Points

The course obviously does not explain this correctly enough. As I have done exactly the same as Lanie, I was getting the same error message and couldn't work out why.

So when you are using a <a> and <li> the <li> stays outside the a? I would never of done that, is it best practise or is it the only way it will work?

Jamie Shankland
Jamie Shankland
798 Points

I managed to get mines working.. whilst moving the <A> inside of the list items.

Jennifer Nordell
seal-mask
.a{fill-rule:evenodd;}techdegree
Jennifer Nordell
Treehouse Teacher

Yes, it is the only way it will work. A list item is the only allowed direct descendent of an ordered list or unordered list. You can find this in the MDN documentation.

On a side note, your problem wasn't exactly like Lanie's. In her question, she forgot the closing angle bracket on the opening anchor tag. I'm not convinced that you also did the same thing.