HTML <menu> Tag

Beginner
5 min read
Updated: Oct 2026
3 examples
Live preview

Definition and Usage

The <menu> element is a semantic alternative to <ul> for an unordered list of items — usually a toolbar of commands the user can perform. Items are <li> elements (often wrapping <button> controls).

Browsers treat menu like ul in the accessibility tree (list role). Prefer menu when the list is interactive commands; use ul for ordinary display lists. Site navigation still belongs in <nav>.

Baseline · Widely available.

Not deprecated as an element. Stable across modern browsers since about July 2015.

Deprecated: compact. Obsolete: context menus.

Do not use compact. The old context-menu role for menu is obsolete. Do not use obsolete <menuitem>.

HTML Syntax

syntax.html
<menu>
  <li><button type="button">Copy</button></li>
  <li><button type="button">Paste</button></li>
</menu>

Both start and end tags are required. Put only list items (plus optional script / template) as children.

Attributes

<menu> mainly uses globals. Avoid the deprecated compact attribute.

AttributeDescriptionTry it
(none required)A bare <menu> with <li> children is enoughTry it
compactDeprecated — use CSS line-height insteadAvoid
vs <ul>Same list mechanics; menu hints at commands / toolbarTry it
Actions in liPut button or links inside each itemTry it

Global Attributes

The <menu> tag also supports the Global Attributes in HTML.

Live Preview

Switch demos to see a toolbar menu, a plain ul, and article actions.

Preview

HTML Examples

Short, copy-ready snippets. Use Try It Yourself for a live editor.

Example 1 — Editing Toolbar

A menu of command buttons.

HTML
<menu>
  <li><button type="button">Copy</button></li>
  <li><button type="button">Cut</button></li>
  <li><button type="button">Paste</button></li>
</menu>
Try It Yourself

How It Works

  1. Open <menu> for a command list.
  2. Add one <li> per action.
  3. Put a <button type="button"> inside each item.
  4. Wire clicks in JavaScript (or forms) as needed.

Example 2 — menu vs ul

Same structure; different author intent. Browsers expose both as lists.

HTML
<!-- Commands -->
<menu>
  <li><button type="button">Save</button></li>
</menu>

<!-- Display list -->
<ul>
  <li>Milk</li>
  <li>Eggs</li>
</ul>
Try It Yourself

How It Works

  1. Choose menu when items are actions to run.
  2. Choose ul when items are content to read.
  3. Expect similar default bullets unless you restyle with CSS.
  4. Keep site nav in nav, not as a substitute for either.

Example 3 — Actions Beside Content

A small action menu next to an article teaser.

HTML
<article>
  <p>Deepest infrared image of the universe yet.</p>
  <menu>
    <li><button type="button">Save for later</button></li>
    <li><button type="button">Share</button></li>
  </menu>
</article>
Try It Yourself

How It Works

  1. Keep content outside the menu (title, paragraph, …).
  2. Group related commands in one menu.
  3. Label buttons clearly so the action is obvious.
  4. Style as a row with CSS when you want a toolbar look (list-style: none, flex).

Edge Cases & Pitfalls

Most menu bugs are wrong children, deprecated attrs, or confusing it with site navigation.

children

Only list-shaped children

Use li (plus optional script/template). Do not drop bare text as a direct child.

deprecated

Do not use compact

Presentational and deprecated. Tighten spacing with CSS instead.

obsolete

No HTML context menus

The old context-menu feature and menuitem are obsolete. Build menus with buttons/links + script if needed.

nav

menu is not site navigation

Primary page/site links belong in nav. Reserve menu for command toolbars.

expectation

Do not expect a special widget

Browsers do not magically create a Mac-style menu bar. You get a list; style and behavior are yours.

Browser Support

The <menu> element is core HTML in every modern browser. It is not a Node.js, Deno, or Bun API.

✓ Baseline · Widely available

<menu>

Widely available since about July 2015. Treated like ul for accessibility. Context-menu features are obsolete.

98% Global support (approx.)
Google Chrome All
Full support
Mozilla Firefox All
Full support
Apple Safari All
Full support
Microsoft Edge All
Full support
Opera All
Full support
Samsung Internet All
Full support
Internet Explorer All
Supported
<menu> Widely supported

Bottom line: Safe as a semantic toolbar list. Style it yourself; avoid compact and menuitem.

Key Takeaways

  • Role: <menu> lists commands; browsers treat it like ul.
  • Structure: li + button (or links) for each action.
  • vs ul / nav: display lists → ul; site links → nav.
  • Avoid: compact, context-menu APIs, and menuitem.

One line: <menu><li><button>… for a toolbar of actions.

Default CSS Settings

Engines typically style menu like an unordered list:

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

/* Common toolbar restyle */
menu.toolbar {
  list-style: none;
  display: flex;
  gap: 0.5rem;
  padding: 0;
  margin: 0;
}

Reset bullets and use flex/grid when you want a horizontal command bar.

Frequently Asked Questions

The menu element is a semantic alternative to ul for an unordered list of items — typically a toolbar of commands the user can activate. Browsers treat it like ul in practice.
Author intent: menu leans toward interactive commands; ul toward display lists. Accessibility exposure is the same list role in browsers.
List items with li (and optionally script or template). Put buttons or links inside each li for toolbar actions.
No. compact is deprecated. Control spacing with CSS such as line-height instead.
No. The old context-menu use case is obsolete and not in the current HTML specification.
No for new work. The menuitem element is obsolete. Use button or links inside li instead.

Next: menuitem

See why the menuitem element is obsolete and what to use instead.

menuitem tutorial →

About the author

Mari Selvan M P
Mari Selvan M P 🔗

Developer, cloud engineer, and technical writer

  • Experience 12 years building web and cloud systems
  • Focus Full Stack Development, AWS, and Developer Education

I write practical tutorials so students and working developers can learn by doing—from databases and APIs to deployment on AWS.

10 people found this page helpful