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

Ul vs. Nav element for horizontal navigation bar

I've seen html documents that use a <nav> element in the header to organize the items in a nav bar as opposed to the <ul> and <li> elements used in this series. Is it better to use one method over the other or does it just come down to a choice of semantics?

E.g.

<div class="container"> <nav class="nav-bar"> <a href="#">...</a> ... ... </nav> </div>

or

<div class="container"> <ul class="nav-bar"> <li><a href="#">...</a></li> ... ... </ul> </div>

Thanks! Leo

1 Answer

Nikos Papapetrou
Nikos Papapetrou
6,305 Points

I think you should choose whatever describes better the role of you site. So use semantics. like nav for the navigation bar, main for your main content. It is better for seo reasons too. So you should use main, footer, sections etc. Your code will be also more readable than use only divs.