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
Patricia Davis
942 PointsWhich is the correct way to add link attribute to an UL?
Does it make a difference if i write it like I did below <ul> <a href="#"><li>Home</li></a> <a href="#"><li>About</li></a> <a href="#"><li>Articles</li></a> <a href="#"><li>Contact</li></a> </ul> Or the treehouse version <ul> <li><a href="#">Home</a></li> <li><a href="#">About</a></li> <li><a href="#">Articles</a></li> <li><a href="#">Contact</a></li> </ul>
1 Answer
Zimri Leijen
11,835 PointsThere is a small difference, and that can be desired or not.
If you do it your way (<a> on the outside, <li> on the inside) you include the whole list item in your link, which means the "dot" in front of the list is also included, for example.
Whether or not this is what you want is up to you.
by the way, please use markdown to make the code easier to read in comments, like this:
<ul>
<a href="#"><li>Home</li></a>
<a href="#"><li>About</li></a>
<a href="#"><li>Articles</li></a>
<a href="#"><li>Contact</li></a>
</ul>
Or the treehouse version
<ul>
<li><a href="#">Home</a></li>
<li><a href="#">About</a></li>
<li><a href="#">Articles</a></li>
<li><a href="#">Contact</a></li>
</ul>