Welcome to the Treehouse Community
The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

Ryan Canty
Courses Plus Student 5,665 PointsTurn each list item into a link. The first item should link to cakes.html, the second to pies.html and the third to cand
What is wrong with this code?! I can't for the life of me figure it out....
<!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>
4 Answers

Valeriia O
Courses Plus Student 17,625 PointsYou just need to switch your tags around, with the <li> on the outside and <a> on the inside.
<li><a href="cakes.html">Cakes</a></li>
<li><a href="pies.html">Pies</a></li>
<li> <a href="candy.html">Candy</a></li>

Kayla Novo
Courses Plus Student 2,029 PointsYou are actually hyper linking (<a> tag) on the text of each list item. The list item tag (<li>) is a formatting tag that tells the browser that what is to follow is just a member of the unordered list (<ul>). The anchor tag is actually linking the text which is why it should surround only the text.
I hope that explanation helps.

Valeriia O
Courses Plus Student 17,625 PointsFrom what I understand, it's because <li> is the child element of <ul>, so it has to come before <a>. I would also like someone else to elaborate on this...

Jason Anello
Courses Plus Student 94,592 PointsThis is correct. It would not be valid html if the <li>
tags were inside the <a>
tags.
a
tags can not be direct children of ul
tags
Here's a link to the ul
element section of the html5 specification: https://www.w3.org/TR/html5/grouping-content.html#the-ul-element
The specification is not an easy thing to read but the important thing here is what is listed for "Content Model:" This is the part that tells you what is allowed to be directly inside of the element in question.
Here it states:
Zero or more li and script-supporting elements.
So nothing else besides that can be directly inside a ul.

Quentin Jobs
UX Design Techdegree Graduate 23,575 Points<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>
Ryan Canty
Courses Plus Student 5,665 PointsRyan Canty
Courses Plus Student 5,665 PointsI appreciate the response, thanks! But is there any practical reason for that apart from just passing the lesson? they both do the same thing
Tadej Danev
Courses Plus Student 1,614 PointsTadej Danev
Courses Plus Student 1,614 Pointsthis was it yes, thanks.