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

Why isnt this working

So Im going through the course and Im getting a message that the second anchor tag isn't correct. Im thinking its an error with the site itself and not something Im doing but I could be wrong. Any help would be appreciated.

<!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>

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>

1 Answer

Steven Parker
Steven Parker
229,732 Points

It's odd the error message is focused on the second tag, as all of the anchor tags should be inside the list items. Right now, they're sort of "inside out".

A good rule to remember is that lists (either "ol" or "ul) are only allowed to have list items ("li") as direct children.