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

CSS CSS Flexbox Layout Building a Layout with Flexbox Building a Navigation Bar with Flexbox

Why do we use unordered list for nav menus

I was just curious as to why we use unordered list in the navigation menu. can we not just use a main-nav div and then each nav items as separate divs inside? Is there any advantage of using unordered lists? because we end up removing the default list styling anyway. Thanks

One reason to use the <nav>, <ul>, <li> tags when building a navigation menu is that semantic markup will improve accessibility for users that require screen-readers. My understanding of how a screen-reader works is that the technology will have difficulty parsing (maybe even skip over) <div class="main-nav"> so it is advantageous to use semantic tags, especially for your global navigation system.

I cannot recall a time where I used <div> tags for each nav-item, however, I have used <a> tags within a <div> (as a container) and have had much success...with the exception of down-graded accessibility for users with special needs!

Thanks Mister Moody.

3 Answers

👍🏾

Seems it's just been used so often it has become the standard (you could probably get away with anchor tags) and it's become easier for screen readers mainly.

I am not sure as I have yet to try creating a navigation list using the div element instead of the ul, but I think the ul being a block element would require less CSS code. I suppose if each list item were a div there would be more flexibility of design. I will have to try it!