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

JavaScript JavaScript Basics (Retired) Making Decisions with Conditional Statements Introducing Conditional Statements

order of li and a tags

https://w.trhou.se/s0v8lx29a9 ok, I think that is a link to the code that I'm curios about Does it matter if I wrap the li in the a tag, or wrap the a tag in the li Both work, as far as I can tell. I thought maybe putting the li inside the a made styling easier, but im not sure

2 Answers

ok, ty for that. Is it just a "rule"? like the universe will hate me? or will something bad happen code wise? Thank you in advance for clearing this up for me

Ryan Field
Ryan Field
Courses Plus Student 21,242 Points

Modern browsers are pretty forgiving, and in most cases will try to "correct" your mistakes in the best way it can. With this particular case, nothing bad would probably happen with your code, but I don't know about every version of every browser. It's possible that there are browsers out there that wouldn't know what to do with this code, so it's always best to use proper semantic markup.

Ryan Field
PLUS
Ryan Field
Courses Plus Student 21,242 Points

Hi, John. To have proper semantic markup, <a> tags should always go inside <li> tags. In fact, nothing should ever go outside of <li> tags. :)