👀 Live Preview
Modern replacement: buttons inside a menu-style container:

Understanding HTML elements is crucial in web development. This guide explains the <menuitem> tag, its deprecated status, and the modern alternatives beginners should use.
How <menuitem> defined commands inside <menu> elements.
Why HTML5 removed menuitem from recommended usage.
Key attributes that described menu command text and behavior.
Save, Copy, Paste patterns inside menu containers.
Replace menuitem with accessible <button> elements.
Use <a> links for navigational menu items.
<menuitem> Tag?The <menuitem> element is an HTML tag used primarily within the <menu> element to represent a command or action that the user can invoke from a context menu or toolbar menu — such as Save, Copy, or Paste.
The <menuitem> tag has been deprecated and should be avoided in favor of modern alternatives like <button> and <a> to ensure compatibility and adherence to web standards.
Modern browsers do not render native menuitem UI. Learn the tag to read legacy code; build interactive menus with buttons, links, and JavaScript in all new work.
The <menuitem> tag is a void element (self-closing). Place it inside a <menu> parent:
<menuitem label="Save"><menuitem> is a void element — no closing tag with content inside.<menu> element (or be associated via the command attribute).label attribute for visible command text.onclick or the command attribute.<menu>
<menuitem label="Save" onclick="saveFunction()">
<menuitem label="Copy" onclick="copyFunction()">
<menuitem label="Paste" onclick="pasteFunction()">
</menu>| Topic | Code Snippet | Notes |
|---|---|---|
| Basic item | <menuitem label="Save"> | Deprecated |
| With click handler | onclick="save()" | Global event attribute |
| Item type | type="command" | command, checkbox, radio |
| Disabled item | disabled | Non-interactive state |
| button replacement | <button type="button"> | Modern approach |
| Browser support | None | Not supported |
The <menuitem> element supported tag-specific attributes plus global attributes like id, class, and event handlers:
label TextVisible name of the menu command shown to the user.
label="Save"type KindCommand type: command (default), checkbox, or radio.
type="command"icon ImageURL of an icon displayed beside the command label.
icon="/icons/save.svg"disabled StatePrevents the user from invoking the command.
disabledonclick EventGlobal event handler to run JavaScript when the item is activated.
onclick="saveFunction()"command ReferenceID of another element that defines the command behavior.
command="save-cmd"All menuitem-specific behavior is deprecated. Use <button> with type="button" and JavaScript event listeners in new projects.
Legacy menuitem patterns and modern button/anchor replacements. Demos use styled buttons because native menuitem is not supported in modern browsers.
Modern replacement: buttons inside a menu-style container:
The <menuitem> tag was used inside <menu> to define items in context menus, giving users actions like Save, Copy, and Paste. Today use <button> or <a> elements with proper styling and event handling.
Define Save, Copy, and Paste commands inside a <menu> with <menuitem> elements.
<menu>
<menuitem label="Save" onclick="saveFunction()">
<menuitem label="Copy" onclick="copyFunction()">
<menuitem label="Paste" onclick="pasteFunction()">
</menu>Use <button> elements styled as menu items with event listeners for interactivity.
<div role="toolbar" aria-label="Edit">
<button type="button" onclick="saveFunction()">Save</button>
<button type="button" onclick="copyFunction()">Copy</button>
<button type="button" onclick="pasteFunction()">Paste</button>
</div>Use <a> elements with styling and handlers for navigational menu items.
<nav aria-label="Quick links">
<ul>
<li><a href="/docs">Docs</a></li>
<li><a href="/settings">Settings</a></li>
<li><a href="/help">Help</a></li>
</ul>
</nav>Given the deprecation of the <menuitem> tag, use these approaches to achieve similar functionality:
<button> element — Style buttons as menu items and attach click event listeners for actions like Save or Copy.<a> element — Use anchor links with appropriate styling for navigational menu items that lead to other pages.<li> + button/a inside nav — Build structured, keyboard-accessible dropdown and toolbar menus.Interactive menu items must work for all users:
<button type="button"> is focusable and activatable with Enter and Space.role="toolbar" and aria-label to groups of action buttons.:focus-visible outlines.Add void <menuitem> elements with label inside a <menu> container.
Supporting browsers rendered clickable command items. Modern browsers skip this entirely.
Event handlers like onclick ran functions when a command was selected.
Learn menuitem for history. Build commands with <button> and accessible JavaScript.
Since the <menuitem> tag is deprecated, its usage is discouraged and it is not supported in modern browsers. Test in target environments before relying on any menu behavior.
Chrome, Firefox, Safari, Edge, Opera, and Internet Explorer do not render native menuitem commands. The element is ignored in the DOM as interactive UI.
Bottom line: Do not use <menuitem> in new projects. Use <button> and <a> elements instead.
While the <menuitem> tag served a purpose in earlier versions of HTML, its deprecated status in HTML5 necessitates the adoption of modern alternatives.
Understanding its limitations and exploring <button> and <a> approaches will ensure compatibility and future-proof your web projects.
<button type="button"> for menu actions<a href> for navigational menu linksaria-label to toolbar groupsmenuitem only to read legacy HTML<menuitem> in new HTML code<menuitem>Bookmark these before you build interactive menus.
<menuitem> defined actions inside <menu>.
Removed from recommended HTML5 usage.
StatusSelf-closing tag with label attribute.
Buttons replace menuitem for actions.
AlternativeLinks replace menuitem for navigation.
AlternativeNo modern browser renders menuitem UI.
Compatibilitymenuitem was a void command element. li is a list item that wraps buttons or links in modern menus.<button> for actions and <a> for navigation, often inside <li> within <nav>.Skip obsolete menuitem. Practice accessible button-based menus in the Try It editor.
6 people found this page helpful