HTML tagLists

<menu>

A list of commands, for example a toolbar with buttons. It works like `<ul>`.

Display
block
Closing tag
Required
Permitted content
<li> elements (<script> and <template> are also allowed)
On this page

Example

#
HTML
<style>
  .toolbar { display: flex; gap: 8px; padding: 0; list-style: none; }
</style>
<menu class="toolbar" aria-label="Editor actions">
  <li><button type="button">Copy</button></li>
  <li><button type="button">Format</button></li>
  <li><button type="button">Run</button></li>
</menu>
Preview

Definition and usage

#

The <menu> element is a semantic variant of <ul> meant for a list of commands the user can perform: an editor toolbar, actions under a comment, “Copy”, “Share”, and “Delete” buttons. You write the items in <li>, and in them you usually put <button> elements.

Browsers and assistive technologies treat <menu> the same as <ul>: it has the same default styles and is announced as a regular list. The old ideas for context menus (the type attribute and the <menuitem> element) were removed from the specification.

Despite its name, <menu> doesn’t turn into a dropdown menu and doesn’t get the ARIA menu role. For navigation around the site use <nav> with a list of links, and leave <menu> for lists of commands.

Syntax

#
Syntax
<menu>
  <li><button type="button">…</button></li>
</menu>

Attributes

#

This element has no attributes of its own. It supports the global attributes, such as class, id and hidden.

Default CSS

#

Most browsers display this element with these default styles:

CSS
menu {
  display: block;
  list-style-type: disc;
  margin-block: 1em;
  padding-inline-start: 40px;
}

Browser support

#

Widely available

Works in all modern browsers, phones included. You can use it without worry.

  • Chrome
  • Edge
  • Firefox
  • Safari

Good practices

#
  • Don’t add role="menu" just because the element is called <menu>. That role requires full keyboard handling (arrows, Escape), which the browser won’t provide on its own.
  • If the items are links to other pages, that is navigation: use <nav> with a <ul> list.

Related entries

#

Spotted a mistake or missing an example? Write to us.