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 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,253 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,253 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>