<command>
The <command> element was designed to represent a command that a user could invoke, typically as part of a menu or toolbar. It was intended to work with the <menu> element to create context menus and command lists. However, this element has been removed from the HTML Living Standard and was only ever partially implemented in a single browser (Firefox, briefly).
This page was last updated on 2025-11-17
Deprecation Warning
DO NOT USE THIS ELEMENT. The <command> element has been removed from the HTML specification. It had extremely limited browser support (only Firefox for a brief period) and is not recognized by any current browser.
Using this element in your code will have no effect. Browsers will treat it as an unknown element and ignore its intended functionality. Your HTML will remain valid, but the element will not provide any interactive features.
History
The <command> element was part of the HTML5 specification for several years, intended to:
- Define commands within context menus
- Create toolbar buttons with specific actions
- Provide a declarative way to define user interface commands
- Support checkable commands (like checkboxes or radio buttons)
The element was removed because:
- Only Firefox implemented it (versions 8-24, then removed)
- Other major browsers showed no interest in implementation
- The use cases were better served by JavaScript and custom elements
- The <menu> element itself had poor support
- Web Components emerged as a more flexible alternative
Original Syntax
The <command> element was a void (self-closing) element:
<command type="command" label="Command Label" icon="icon.png">
Original Attributes
- type — Type of command: "command", "checkbox", or "radio"
- label — The name of the command shown to the user
- icon — URL of an image to represent the command
- disabled — Whether the command is disabled
- checked — For checkbox/radio types, whether it’s selected
- radiogroup — Name of the group for radio-type commands
Example of Intended Usage (Non-functional)
<!-- This code does NOT work in any browser -->
<menu type="toolbar">
<command type="command" label="Save" icon="save.png" onclick="save()">
<command type="command" label="Open" icon="open.png" onclick="open()">
<command type="checkbox" label="Bold" checked onclick="toggleBold()">
</menu>
Modern Alternatives
Use these approaches instead of the deprecated <command> element:
Standard Buttons
<button type="button" onclick="saveDocument()">
<img src="save-icon.png" alt=""> Save
</button>
Toolbar with Buttons
<div role="toolbar" aria-label="Document actions">
<button type="button">Save</button>
<button type="button">Open</button>
<button type="button" aria-pressed="false">Bold</button>
</div>
Custom Context Menu
<div class="context-menu" hidden>
<button type="button">Cut</button>
<button type="button">Copy</button>
<button type="button">Paste</button>
</div>
<script>
document.addEventListener('contextmenu', function(e) {
e.preventDefault();
// Show custom context menu
});
</script>
These alternatives provide better browser support, accessibility, and control over the user interface.
Related Elements
- <button> — The standard element for interactive buttons
- <menu> — Menu container (has limited support)
- <bb> — Another deprecated/never-implemented element
- <datagrid> — Another removed element from early HTML5
- <input> — For various form controls including checkboxes and radio buttons