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 {{HTMLElement("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 {{Glossary("empty element")}}. |
Tag omission | The start tag is mandatory, but, as it is a void element, the use of an end tag is forbidden. |
Permitted parent elements | {{HTMLElement("colgroup")}} only, though it can be implicitly defined as its start tag is not mandatory. The {{HTMLElement("colgroup")}} must not have a {{HTMLElement("span")}} as child. |
DOM interface | {{domxref("HTMLCommandElement")}} |
This element includes the global attributes.
type
attribute is checkbox
or radio
.type
of radio
, that will be toggled when the command itself is toggled. This attribute must be omitted unless the type
attribute is radio
.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 |
---|---|---|
{{SpecName('HTML WHATWG', '#commands')}} | {{Spec2('HTML WHATWG')}} | |
{{SpecName('HTML5 W3C', 'semantics.html#the-command-element', '<command>')}} | {{Spec2('HTML5 W3C')}} |
{{Compat("html.elements.command")}}
{{ HTMLRef }}