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

why nest <li><a href></a></li> as opposed to <a href><li></li></a>? technical reason or is it a convention we stick to?

Is there a technical reason for the way everyone nests the link refs inside of the list items, it seems to me that it works both ways around. Is it just one of those things that there was a fork in the road so they all chose the same way so they weren't creating confusion.

2 Answers

It's not valid HTML because the only thing allowed inside an unordered (ul) or ordered list (ol) is a list item (li). It's just a syntax rule where the computer expects to see list items as direct children of lists. Kinda like in English, we expect verbs and nouns to be in certain arrangements and it throws us off if they aren't.

Thanks Meg.

I was wondering the same thing, because if you do it the second way and put it in the W3C validator, it will give you an error.