HTML <menu> Tag

The <menu> tag defines a list of commands. It is used for creating context menus, toolbars and listing form controls and commands.

Each list item in <menu> tag starts with the <li> or the <menuitem> elements.

The <menu> tag has been deprecated in HTML 4.01 and redefined in HTML5. It works only for context menus. Use the <ul> element instead.

Syntax

The <menu> tag comes in pairs. The content must be written between opening (<menu>) and closing (</menu>) tags.

Example

<!DOCTYPE html>
<html>
  <head>
    <title>Title of the document</title>
    <style>
      menuitem {
        display: block;
      }
    </style>
  </head>
  <body>
    <menu>
      <menuitem>ol - ordered list</menuitem>
      <menuitem>ul - unordered list</menuitem>
      <menuitem>menu - menu list</menuitem>
    </menu>
  </body>
</html>

Result

Let's see another example where the <menu> tag is used to create a context menu:

Example

<!DOCTYPE html>
<html>
  <head>
    <title>Title of the document</title>
  </head>
  <body>
    <div style="background:#1c87c9; padding: 20px; text-align:center; color:#ffffff;" contextmenu="menuexample">
      <p>Right-click inside this box to open the context menu</p>
      <menu type="context" id="menuexample">
        <menuitem label="Refresh" onclick="window.location.reload();"></menuitem>
        <menu label="Share on...">
          <menuitem label="Twitter" onclick="window.open('//twitter.com/intent/tweet?text=' + window.location.href);"></menuitem>
          <menuitem label="Facebook" onclick="window.open('//facebook.com/sharer/sharer.php?u=' + window.location.href);"></menuitem>
        </menu>
        <menuitem label="Email This Page" onclick="window.location='mailto:?body='+window.location.href;"></menuitem>
      </menu>
    </div>
    <p><span style="color:red;">Reminder:</span> This works only in Firefox.</p>
  </body>
</html>

Result

Attributes

Attribute Value Description
label text Defines a visible label for the menu.
type popup
toolbar
context
Defines the type of the menu.

The <menu> tag also supports the Global attributes and the Event Attributes.

Browser support

8+