Question

I thank that if i want to create a menu in html, i should use ul tag. But I have just discovered menu tag, so i wanna know, which tag is preferable to create menus. It is

<ul>                                          <menu>
<li>LOL</li>                                  <li>LOL</li>
<li>Mmmm</li>                                 <li>Mmmm</li>
</ul>                                         </menu>

the same thing?

Was it helpful?

Solution

if you are trying to create a navigation bar (whether is in the top, side, or bottom of your site), the correct semantic mark up would be..

<nav>
  <ul>
    <li>Menu Item One</li>
    <li>Menu Item Two</li>
    <li>Menu Item Three</li>
    ...
  </ul>
</nav>

Note that you still need a list (<ul> or <ol>) inside of the <nav>. Semantically, The nav element represents a section of a page that links to other pages or to parts within the page: a section with navigation links.

<nav>
  <li>Menu Item One</li>
  <li>Menu Item Two</li>
  ...
</nav>

WILL NOT WORK.

<menu> is for a menu of controls for say a web app or a game or something, not for navigation. Subtle but important semantic difference. Also note that <menu> does not seem to be supported by any major browsers a the time of this post

OTHER TIPS

This is my go to HTML for a menu.

  <ul>
    <li><a href="#">One</a></li>
    <li><a href="#">Two</a></li>
  </ul>

This question should clear up a lot of things for you: <nav> or <menu> (HTML5)

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top