Home HTML Tags <menu> Definition
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> .
Syntax
HTML Syntax <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.
Reference
Attributes <menu> mainly uses globals. Avoid the deprecated compact attribute.
Attribute Description Try it (none required) A bare <menu> with <li> children is enough Try itcompactDeprecated — use CSS line-height insteadAvoid vs <ul> Same list mechanics; menu hints at commands / toolbar Try itActions in li Put button or links inside each item Try it
Try it
Live Preview Switch demos to see a toolbar menu, a plain ul, and article actions.
Code
HTML Examples Short, copy-ready snippets. Use Try It Yourself for a live editor.
1. Toolbar 2. menu vs ul 3. Article actions Example 1 — Editing Toolbar A menu of command buttons.
<menu>
<li><button type="button">Copy</button></li>
<li><button type="button">Cut</button></li>
<li><button type="button">Paste</button></li>
</menu> How It Works Open <menu> for a command list.Add one <li> per action .Put a <button type="button"> inside each item.Wire clicks in JavaScript (or forms) as needed.Example 2 — menu vs ul Same structure; different author intent. Browsers expose both as lists.
<!-- Commands -->
<menu>
<li><button type="button">Save</button></li>
</menu>
<!-- Display list -->
<ul>
<li>Milk</li>
<li>Eggs</li>
</ul> How It Works Choose menu when items are actions to run.Choose ul when items are content to read.Expect similar default bullets unless you restyle with CSS.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.
<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> Deepest infrared image of the universe yet.
Save for later Share How It Works Keep content outside the menu (title, paragraph, …).Group related commands in one menu.Label buttons clearly so the action is obvious.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 navigationPrimary 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.
Compatibility
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.
Remember
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.
UA style
Default CSS Settings Engines typically style menu like an unordered list:
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 What is the HTML menu tag used for? 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.
How is menu different from ul? Author intent: menu leans toward interactive commands; ul toward display lists. Accessibility exposure is the same list role in browsers.
What goes inside menu? List items with li (and optionally script or template). Put buttons or links inside each li for toolbar actions.
Is the compact attribute OK? No. compact is deprecated. Control spacing with CSS such as line-height instead.
Can menu still make a context menu? No. The old context-menu use case is obsolete and not in the current HTML specification.
Should I use menuitem? 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 Developer, cloud engineer, and technical writer
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
Helpful Share Copy link Suggestion