MDN may have intermittent access issues April 18 13:00 - April 19 01:00 UTC. See whistlepig.mozilla.org for all notifications.

mozilla

Revision 332279 of <command>

  • Revision slug: HTML/Element/command
  • Revision title: <command>
  • Revision id: 332279
  • Created:
  • Creator: teoli
  • Is current revision? No
  • Comment

Revision Content

{{ HTMLVersionHeader(5) }}

Summary

The command element represents a command which the user can invoke.

  • Content categories Flow content, phrasing content, metadata content.
  • Permitted content None, this is a void 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 {{ 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")}}

Attributes

Like all other HTML elements, this element supports the global attributes.

{{ htmlattrdef("checked") }}
Indicates whether the command is selected. Must be omitted unless the type attribute is checkbox or radio.
{{ htmlattrdef("disabled") }}
Iindicates that the command is not available.
{{ htmlattrdef("icon") }}
Gives a picture which represents the command.
{{ htmlattrdef("label") }}
The name of the command as shown to the user.
{{ htmlattrdef("radiogroup") }}
This attribute gives the name of the group of commands, with a type of radio, that will be toggled when the command itself is toggled. This attribute must be omitted unless the type attribute is radio.
{{ htmlattrdef("type") }}
This attribute indicates the kind of command. This can be one of three values.
  • 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 radiobutton.

Examples

<command type="command" label="Save" icon="icons/save.png" onclick="save()">

Specifications

Specification Status Comment
{{ SpecName('HTML WHATWG', 'interactive-elements.html#the-command-element', '<command>') }} {{ Spec2('HTML WHATWG') }}  
{{ SpecName('HTML5 W3C', 'the-command-element.html#the-command-element', '<command>') }} {{ Spec2('HTML5 W3C') }}  

Browser compatibility

{{ CompatibilityTable() }}

Feature Chrome Firefox (Gecko) Internet Explorer Opera Safari
Basic support {{ CompatNo() }} {{ CompatNo() }} {{ CompatNo() }} {{ CompatNo() }} {{ CompatNo() }}
Feature Android Firefox Mobile (Gecko) IE Mobile Opera Mobile Safari Mobile
Basic support {{ CompatNo() }} {{ CompatNo() }} {{ CompatNo() }} {{ CompatNo() }} {{ CompatNo() }}

 

Revision Source

<p>{{ HTMLVersionHeader(5) }}</p>
<h2 id="Summary">Summary</h2>
<p>The <code>command</code> element represents a command which the user can invoke.</p>
<ul class="htmlelt">
  <li><dfn><a href="/en-US/docs/HTML/Content_categories" title="/en-US/docs/HTML/Content_categories">Content categories</a></dfn> <a href="/en/HTML/Content_categories#Flow_content" title="en/HTML/Content categories#Flow content">Flow content</a>, <a href="/en/HTML/Content_categories#Phrasing_content" title="en/HTML/Content categories#Phrasing content">phrasing content</a>, metadata content.</li>
  <li><dfn>Permitted content</dfn> None, this is a void element.</li>
  <li><dfn>Tag omission</dfn> The <span title="syntax-start-tag">start tag</span> is mandatory, but, as it is a void element, the <span title="syntax-end-tag">use an end tag</span> is forbidden.</li>
  <li><dfn>Permitted parent elements</dfn> {{ 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.</li>
  <li><dfn>DOM interface</dfn> {{ domxref("HTMLCommandElement")}}</li>
</ul>
<h2 id="Attributes">Attributes</h2>
<p>Like all other HTML elements, this element supports the <a href="/en/HTML/Global_attributes" title="en/HTML/Global attributes">global attributes</a>.</p>
<dl>
  <dt>
    {{ htmlattrdef("checked") }}</dt>
  <dd>
    Indicates whether the command is selected. Must be omitted unless the <code>type</code> attribute is <code>checkbox </code>or <code>radio</code>.</dd>
  <dt>
    {{ htmlattrdef("disabled") }}</dt>
  <dd>
    Iindicates that the command is not available.</dd>
  <dt>
    {{ htmlattrdef("icon") }}</dt>
  <dd>
    Gives a picture which represents the command.</dd>
  <dt>
    {{ htmlattrdef("label") }}</dt>
  <dd>
    The name of the command as shown to the user.</dd>
  <dt>
    {{ htmlattrdef("radiogroup") }}</dt>
  <dd>
    This attribute gives the name of the group of commands, with a <code>type</code> of <code>radio</code>, that will be toggled when the command itself is toggled. This attribute must be omitted unless the <code>type</code> attribute is <code>radio</code>.</dd>
  <dt>
    {{ htmlattrdef("type") }}</dt>
  <dd>
    This attribute indicates the kind of command. This can be one of three values.
    <ul>
      <li>
        <p><code>command</code> or empty which is the default state and indicates that this is a normal command.</p>
      </li>
      <li>
        <p><code>checkbox</code> indicates that the command can be toggled using a checkbox.</p>
      </li>
      <li>
        <p><code>radio</code> indicates that the command can be toggled using a radiobutton.</p>
      </li>
    </ul>
  </dd>
</dl>
<h2 id="Examples">Examples</h2>
<pre class="brush: html">
&lt;command type="command" label="Save" icon="icons/save.png" onclick="save()"&gt;
</pre>
<h2 id="Specifications" name="Specifications">Specifications</h2>
<table class="standard-table">
  <thead>
    <tr>
      <th scope="col">Specification</th>
      <th scope="col">Status</th>
      <th scope="col">Comment</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td>{{ SpecName('HTML WHATWG', 'interactive-elements.html#the-command-element', '&lt;command&gt;') }}</td>
      <td>{{ Spec2('HTML WHATWG') }}</td>
      <td>&nbsp;</td>
    </tr>
    <tr>
      <td>{{ SpecName('HTML5 W3C', 'the-command-element.html#the-command-element', '&lt;command&gt;') }}</td>
      <td>{{ Spec2('HTML5 W3C') }}</td>
      <td>&nbsp;</td>
    </tr>
  </tbody>
</table>
<h2 id="Browser_Compatibility">Browser compatibility</h2>
<p>{{ CompatibilityTable() }}</p>
<div id="compat-desktop">
  <table class="compat-table">
    <tbody>
      <tr>
        <th>Feature</th>
        <th>Chrome</th>
        <th>Firefox (Gecko)</th>
        <th>Internet Explorer</th>
        <th>Opera</th>
        <th>Safari</th>
      </tr>
      <tr>
        <td>Basic support</td>
        <td>{{ CompatNo() }}</td>
        <td>{{ CompatNo() }}</td>
        <td>{{ CompatNo() }}</td>
        <td>{{ CompatNo() }}</td>
        <td>{{ CompatNo() }}</td>
      </tr>
    </tbody>
  </table>
</div>
<div id="compat-mobile">
  <table class="compat-table">
    <tbody>
      <tr>
        <th>Feature</th>
        <th>Android</th>
        <th>Firefox Mobile (Gecko)</th>
        <th>IE Mobile</th>
        <th>Opera Mobile</th>
        <th>Safari Mobile</th>
      </tr>
      <tr>
        <td>Basic support</td>
        <td>{{ CompatNo() }}</td>
        <td>{{ CompatNo() }}</td>
        <td>{{ CompatNo() }}</td>
        <td>{{ CompatNo() }}</td>
        <td>{{ CompatNo() }}</td>
      </tr>
    </tbody>
  </table>
</div>
<p>&nbsp;</p>
Revert to this revision