Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Should we put <ul> tag inside <nav> tag?

Tags:

html

nav

I wonder many websites put tag inside tag, from the specification the nav tag has anchors tags, and here the example in w3schools, why many sites make like this:

<nav>
    <ul>
        <li><a href="#">Home</a></li>
        <li><a href="#">About</a></li>
    </ul>
</nav>

Is that correct or we should only make like this

<nav>
    <a href="#">Home</a>
    <a href="#">About</a>
</nav>
like image 649
palAlaa Avatar asked Jan 16 '23 23:01

palAlaa


1 Answers

In general it's not required, however it's very common practice to put your navigation items in list and using CSS displaying them inline (if required). That is not only advice for HTML5 - if you'll disable for an example CSS in the browser, your menu will be displayed as:

start about me contact (can you read this?)

with list it will be:

  • start
  • about me
  • contact

Consider yourself which version would you like to see in case of problems with displaying design.

like image 86
biesior Avatar answered Jan 21 '23 20:01

biesior