Obsolete
This feature is obsolete. Although it may still work in some browsers, its use is discouraged since it could be removed at any time. Try to avoid using it.
The HTML Command element (<command>
) represents a command which the user can invoke. Commands are often used as part of a context menu or toolbar. However, they can be used anywhere on the page.
The <command>
element is included in the W3C specification, but not in the WHATWG specification, and browser support is nonexistent. You should use the <menuitem>
element instead, although that element is non-standard and only supported in Edge and Firefox.
Content categories | Flow content, phrasing content, metadata content. |
---|---|
Permitted content | None, it is an empty element. |
Tag omission | The start tag is mandatory, but, as it is a void element, the use an end tag is forbidden. |
Permitted parent elements |
<colgroup> only, though it can be implicitly defined as its start tag is not mandatory. The <colgroup> must not have a <span> as child. |
DOM interface | HTMLCommandElement |
This element includes the global attributes.
checked
type
attribute is checkbox
or radio
.disabled
icon
label
radiogroup
type
of radio
, that will be toggled when the command itself is toggled. This attribute must be omitted unless the type
attribute is radio
.type
command
or empty which is the default state and indicates that this is a normal command.
checkbox
indicates that the command can be toggled using a checkbox.
radio
indicates that the command can be toggled using a radio button.
<command type="command" label="Save" icon="icons/save.png" onclick="save()">
Specification | Status | Comment |
---|---|---|
HTML Living Standard The definition of '<command>' in that specification. | Living Standard | |
HTML5 The definition of '<command>' in that specification. | Recommendation |
Feature | Chrome | Edge | Firefox | Internet Explorer | Opera | Safari |
---|---|---|---|---|---|---|
Basic support | No | No | No1 | No | No | No |
checked |
No | No | No | No | No | No |
disabled |
No | No | No | No | No | No |
icon |
No | No | No | No | No | No |
label |
No | No | No | No | No | No |
radiogroup |
No | No | No | No | No | No |
type |
No | No | No | No | No | No |
Feature | Android webview | Chrome for Android | Edge mobile | Firefox for Android | IE mobile | Opera Android | iOS Safari |
---|---|---|---|---|---|---|---|
Basic support | No | No | No | No1 | No | No | No |
checked |
No | No | No | No | No | No | No |
disabled |
No | No | No | No | No | No | No |
icon |
No | No | No | No | No | No | No |
label |
No | No | No | No | No | No | No |
radiogroup |
No | No | No | No | No | No | No |
type |
No | No | No | No | No | No | No |
1. Before Firefox 24, although not implemented, an object of class HTMLCommandElement
was created, instead of the compliant HTMLUnknownElement
.
© 2005–2018 Mozilla Developer Network and individual contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-US/docs/Web/HTML/Element/command