HTML <menuitem> Element

The <menuitem> element was designed to represent a command that a user could activate from a menu. It was associated with the <menu> element and could describe commands, checkbox-style choices, radio-style choices, and items within browser context menus.

Historical Syntax

HTML documents using <menuitem> could contain markup similar to the following:

<menu type="context" id="page-menu">
  <menuitem label="Refresh"></menuitem>
  <menuitem label="Print"></menuitem>
  <menuitem label="Save"></menuitem>
</menu>

Each <menuitem> represented a command within the menu. In implementations supporting context menus, the menu could be associated with another part of the page and displayed through the browser's context-menu interface. This code is shown for historical reference only and should not be used in modern HTML.

Attributes

The <menuitem> element supported several element-specific attributes for describing the command and its state. These attributes are obsolete along with the element and are included here to help identify older HTML source code.

Attribute Description
checked Indicated that a checkbox or radio menu item was selected.
command Historically associated the menu item with another command element or command definition.
default Indicated that the menu item represented the default command for the menu.
disabled Indicated that the command was unavailable and could not be activated.
icon Specified an image that could be displayed with the menu item.
label Specified the text displayed for the menu command.
radiogroup Assigned a radio-type menu item to a named group so only one item in the group could be selected.
type Specified the type of menu item, such as a command, checkbox, or radio option.

Historical Use

The <menuitem> element was intended to provide semantic markup for commands rather than requiring authors to construct every menu interface from generic elements. Depending on its type, a menu item could behave like a normal command, a checkbox that could be turned on and off, or one choice within a group of radio-style commands.

One of its more interesting uses was the ability to add commands to a browser context menu. A webpage could define a menu and associate it with content so that additional page-specific commands appeared when the visitor opened the context menu.

The idea was useful, but support varied considerably between browsers. Authors could not depend on visitors receiving the same menu functionality across the major browser engines.

Why It Became Obsolete

The <menuitem> element never achieved reliable cross-browser support. Some browsers implemented portions of the menu and context-menu system while others did not implement it at all, making the feature difficult to use on public websites.

The related context-menu model was eventually removed from the HTML standard, and browser implementations of <menuitem> disappeared. Modern HTML already provides well-supported interactive elements that can represent commands and selections without depending on browser-specific context-menu behavior.

The <menuitem> element is obsolete and non-conforming in modern HTML.

Modern Alternative

There is no single HTML element that replaces every historical use of <menuitem>. Choose an element according to the action the visitor needs to perform.

For a group of commands that perform actions on the current page, ordinary <button> elements provide a simple modern structure:

<div class="command-menu">
  <button type="button">Refresh</button>
  <button type="button">Print</button>
  <button type="button">Save</button>
</div>

When the choices represent selectable options rather than commands, use appropriate form controls such as checkboxes or radio buttons. Use links when selecting an item navigates the visitor to another page or resource.

Play in Editor

Legacy Browser Support

Browser support for <menuitem> was limited even while the element was being developed. Some versions of Firefox implemented context-menu functionality, but it was not consistently supported across the major browser engines and support was later removed.

Current webpages should not expect <menuitem> to create a working menu command. Existing markup should be replaced with appropriate modern interactive elements when older webpages are updated.

For detailed legacy browser compatibility information, see Can I Use: HTML <menuitem> Element .

The <menuitem> element was associated with the modern <menu> element. Depending on the required interaction, modern interfaces can use the <button>, <input>, and <a> elements.

Specifications

The <menuitem> element is an obsolete, non-conforming feature in modern HTML and must not be used in new documents. Modern interfaces should use established HTML interactive elements appropriate to the command, selection, or navigation being provided.