HTML <menuitem> Tag

Beginner
5 min read
Updated: Oct 2026
3 examples
Obsolete

Definition and Usage

The <menuitem> element once represented a single command inside a <menu> — mainly for experimental HTML5 context menus. That design was never widely shipped.

Learn it only to recognize legacy docs. For new work, put <button> (or links) inside <li> within <menu>. Custom right-click menus need script that listens for the contextmenu event (HTML Standard guidance).

Obsolete.

Do not use <menuitem>. It is listed as non-conforming in the HTML Standard and removed from practical browser support.

Not a Baseline feature.

Unlike <menu>, <menuitem> has no modern implementation path. Treat it as archive knowledge only.

HTML Syntax

syntax.html
<!-- Obsolete — do not use -->
<menuitem label="Save" type="command">

Modern equivalent: <menu><li><button type="button">Save</button></li></menu>

Attributes

Legacy attributes (study only). None of these make menuitem valid today.

AttributeDescriptionTry it
labelLegacy — visible name of the commandTry it
typeLegacy — command, checkbox, or radioAvoid
icon / radiogroup / commandLegacy — icon URL, radio group name, or linked command idAvoid
disabled / checkedLegacy — inactive or selected state for checkbox/radio itemsAvoid
Use <button> insteadCorrect today — inside menu → liTry it

Global Attributes

The <menuitem> tag also supports the Global Attributes in HTML (legacy recognition only — do not author new menuitem markup).

Live Preview

Compare inert legacy markup with a working menu + button toolbar.

demo style
Preview

HTML Examples

Short snippets for study and migration. Use Try It Yourself for a live editor.

Example 1 — Legacy menuitem (Study Only)

Recognize old samples. This will not create a modern context menu.

HTML
<!-- Obsolete — for study only -->
<menu>
  <menuitem label="Save" type="command">
  <menuitem label="Share" type="command">
</menu>
Try It Yourself

How It Works

  1. Spot the tag name in old tutorials or specs.
  2. Read label / type as historical command metadata.
  3. Expect no useful UI in modern engines.
  4. Plan a rewrite to button (or custom scripted menus).

Example 2 — Preferred: menu + button

Valid toolbar commands without menuitem.

HTML
<menu>
  <li><button type="button">Save</button></li>
  <li><button type="button">Share</button></li>
</menu>
Try It Yourself

How It Works

  1. Keep <menu> for a command list.
  2. Wrap each action in <li>.
  3. Use <button type="button"> instead of menuitem.
  4. Handle clicks in JavaScript when the action is scripted.

Example 3 — Custom Menu Pattern (No menuitem)

Show actions with a button that reveals choices — no obsolete tags.

HTML
<button type="button" id="more" aria-expanded="false" aria-controls="more-menu">
  More actions
</button>
<menu id="more-menu" hidden>
  <li><button type="button">Duplicate</button></li>
  <li><button type="button">Delete</button></li>
</menu>

<script>
  var btn = document.getElementById("more");
  var panel = document.getElementById("more-menu");
  btn.addEventListener("click", function () {
    var open = panel.hidden;
    panel.hidden = !open;
    btn.setAttribute("aria-expanded", open ? "true" : "false");
  });
</script>
Try It Yourself

How It Works

  1. Use a real button to open/close the panel.
  2. Keep choices in menu + li + button.
  3. Toggle hidden and mirror state with aria-expanded.
  4. For right-click menus, listen for contextmenu in script — do not use menuitem.

Edge Cases & Pitfalls

The main risk is copying obsolete HTML5 menu samples into new projects.

obsolete

Do not use in new HTML

Validators reject <menuitem>. Rewrite to buttons inside menu/li.

contextmenu

No declarative HTML context menus

The old menu type="context" + menuitem path is gone. Use the contextmenu event + your own UI.

confusion

menu is not obsolete

<menu> remains valid. Only <menuitem> (and the context-menu feature) are obsolete.

aria

ARIA role="menuitem" is different

The ARIA role name is unrelated permission to use the obsolete HTML element. Prefer native buttons when you can.

migration

Replace labels with button text

Old label="Save" becomes <button>Save</button> (visible text, not an attribute-only name).

Browser Support

<menuitem> is an obsolete HTML element. Prefer <button> inside <menu> / <li>.

✓ Obsolete · Not supported

<menuitem>

Removed from the HTML Standard for authors. No reliable modern browser support for the old context-menu design.

0% Practical support (approx.)
Google Chrome Removed / unused
Obsolete
Mozilla Firefox Removed / unused
Obsolete
Apple Safari Not supported
Obsolete
Microsoft Edge Removed / unused
Obsolete
Opera Removed / unused
Obsolete
Samsung Internet Not supported
Obsolete
Internet Explorer N/A
Obsolete
<menuitem> Do not use

Bottom line: Do not depend on menuitem. Ship buttons in a menu list, or build a custom scripted menu.

Key Takeaways

  • Status: <menuitem> is obsolete — study it, do not ship it.
  • Replacement: menu → li → button.
  • Context menus: use the contextmenu event + your own UI.
  • Keep menu: the <menu> element itself is still valid.

One line: recognize <menuitem>, replace it with <button> in a <menu>.

Default CSS Settings

There is no meaningful modern UA stylesheet for menuitem. Prefer styling real controls:

default.css
/* Do not style menuitem for new work */

menu {
  list-style: none;
  padding: 0;
}

menu button {
  /* your toolbar button styles */
}

Delete any CSS selectors targeting menuitem when you migrate legacy pages.

Frequently Asked Questions

No. The menuitem element is entirely obsolete. Authors must not use it. Modern browsers do not implement it as a working menu command.
It once represented a command inside a menu — especially experimental HTML5 context menus. That feature was removed from the HTML Standard.
For toolbars, use menu with li and button (or links). For custom context menus, handle the contextmenu event in script and build an accessible menu UI yourself.
Not as a useful widget. Support was never broad; remaining engines ignore or strip the feature. Treat any old markup as dead code.
menu remains valid as a list of commands. menuitem does not. Put buttons inside li children of menu instead.
Legacy drafts used label for the visible name and type for command, checkbox, or radio items. Those attributes are historical only — do not ship them on menuitem.

Use button instead

Build command toolbars with menu, li, and button.

button 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.

7 people found this page helpful