Leo Sherman
Leo Sherman
2,969 Points

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?


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


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

Thanks! Leo

1 Answer

Νίκος Παπαπέτρου
Νίκος Παπαπέτρου
5,495 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.