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.

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!