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

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!