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

TRI NGUYEN
TRI NGUYEN
1,122 Points

How does one solve this coding problem ?

I seem to have typed up the code correctly, but it gives me the message that the pies.html file needs to be placed in a href tag, despite me already doing that

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>

2 Answers

Conrad Cortes
Conrad Cortes
8,418 Points

So close! See if you can spot the difference in mine...

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

You want the item in the list to be a link, not the list itself. The way you have it would work if you were making your own site but it would be slightly different and I guess the challenge wants it done a specific way.

Also... remove the space between the href = and your ". This is technically bad syntax. While the browser will correct this is most cases, it is still considered incorrect. This will develop a bad habit that will slow you down when learning other languages, and if you are required to do any projects in xhtml in the future, then this will surely be a problem.

<a href="cakes.html"><li>Cakes</li></a>
 <a href="pies.html"><li>Pies</li></a>
 <a href="candy.html"><li>Candy</li></a>

But Conrad is also right... it should look more like this moving forward. Again, it will work both ways, but it is better to have your links for such things nested inside of list elements, instead of lists nested in the anchor element. Nesting is important, as you'll come to see later in deeper lessons.

<li><a href="cakes.html">Cakes</a></li>
<li><a href="pies.html">Pies</a></li>
<li><a href="candy.html">Candy</a></li>