Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

html5 NAV TAG proper usage

I've begun to use html tags on my pages, and I'm trying to determine what is the proper usage of the NAV tag. I've read the documentation, and it seems like I should be okay with what I have, but I noticed that most other developers have their navigation 'blocks' within "ul" "li" tags. I've using divs.

My question is, what are the pros / cons to using "ul" "li" tags rather than divs?

And would the following work with nav?

<nav>
    <div id="navBar">
        <div id="navItem1"><a></a></div>
        <div id="navItem2"><a></a></div>
        <div id="navItem3"><a></a></div>
        <div id="navItem4"><a></a></div>
    </div>
</nav>
like image 617
Saahir Foux Avatar asked Dec 21 '22 10:12

Saahir Foux


1 Answers

The code you posted isn't a best practice. It should be:


<nav>
    <ul>
        <li><a></a></li>
        <li><a></a></li>
        <li><a></a></li>
        <li><a></a></li>
    </ul>
</nav>

<ul> and <li> tags are better than using div tags, and are almost always used for menus. By using uls and lis, you don't clog up your code with WAY too many IDs.

like image 199
ayyp Avatar answered Dec 28 '22 05:12

ayyp