htmlmenuhtml-lists

Which tag is used to create menus, ul or menu?


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?


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