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 trialDiego Morejon
1,663 PointsHi, my im getting an Error Message, even though my Anchor tag should be correct. ..
<a href="pies.html"> <li> Pies</li></a>
why though?
<!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>
5 Answers
Stuart Lockhart
8,861 PointsYou are putting your <li> iin the wrong place. Write it like this:
<li><a href=cakes.html>Cakes</a></li>
Katie Wood
19,141 PointsHi there,
Just thought it might be worth mentioning that, while browsers may render it the way you'd expect, technically <li> is the only permitted element child of a <ul> in HTML (see here(MDN) and here(W3C)).
It might work otherwise, but the intended usage is to have <li> tags inside your <ul> or <ol>, and then put anything else you want inside those. I haven't really messed with breaking that rule myself, so I'm not sure if there's specific unexpected behavior that might occur if you switch things around, but thought the docs might be of interest.
Happy coding!
Diego Morejon
1,663 PointsThank you, that was it !
Question: does it really matter? where I put the Anchor Tag, on my own project I placed the Anchors outside the List item and it still works.
Thank you for your time!
Stuart Lockhart
8,861 PointsIn Treehouse they need very specific answers, sometimes the code should work but the code challenge will say its wrong USUALLY because its trying to show you good coding practices. In this case I'd say put the anchor tag inside.
Stuart Lockhart
8,861 PointsAlthough either will work, and sometimes its better the other way around. Don't worry too much about it.