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.

HTML How to Make a Website Creating HTML Content Create Navigation with Lists

Joseph Longo
Joseph Longo
1,074 Points

Anchors: Inside or Outside?

I noticed in the code example, the anchor tags were like this: <li><a href="null">some link</a></li>

Is there a reason to do it this way, such as CSS or could I have done this, too <a href="null"><li>some link too</li></a>

Joseph Longo
Joseph Longo
1,074 Points

It's not displaying my html...Give me a second and I will attach a file.

2 Answers

Jonathan Grieve
MOD
Jonathan Grieve
Treehouse Moderator 91,028 Points

It is common to nest other elements in Anchor tags. You can do this to turn images into links in just the same way.

In this example, it'll turn both heading texts to go to the same link.

Hope this helps. :)

Joseph Longo
Joseph Longo
1,074 Points

Would it be semantically correct to reverse the order and nest the list items inside the anchor tags as opposed to have the anchor tags nested inside the list items?

Joseph Longo
Joseph Longo
1,074 Points

It won't show my html, but you basically answered my question. In the example, the anchor tags were nested inside the list item elements. So, my question was could I have reversed the order and nest the list item elements inside the anchor tags?

Jonathan Grieve
Jonathan Grieve
Treehouse Moderator 91,028 Points

Hi Joseph, I'm glad I helped. I'm not sure where your code went

But yes you can next as many anchor elements inside as many list item elements as you like, so this would work.

<ul>
<li><a href="">Anchor text</a></li>
<li><a href="">Anchor text</a></li>
<li><a href="">Anchor text</a></li>
</ul>