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!

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

Anchor element inside inside element

In this exercise, I see Mr. Nick put anchor element inside list element. Is there any semantic meaning to it?

Here is the code

                    <!--anchor element is a child to list element here.-->
                    <li><a href="index.html">Projects</a></li>
                    <li><a href="about.html">About</a></li>
                    <li><a href="contact.html">Contact</a></li>

It seems wrapping list element with anchor element have the same result.

                    <!--list element is a child to anchor element here.-->
                    <a href="index.html"><li>Projects</li></a>
                    <a href="about.html"><li>About</li></a>
                    <a href="contact.html"><li>Contact</li></a>

1 Answer

Yes, it is semantic becouse <li> have to be a direct child of a <ul> (unordered) or <ol> (ordered list) and <a> creates the navigation meaning you can click on a link and go to another page.

Alex Age Very sorry. I do not get it.

Post updated

You mean html <li> should be direct child of html <ul> or <ol>?

Yes, I do.

Alex Age Thank you so much for detailed explanation.

You're welcome!