<command>

  • Revision slug: HTML/Element/command
  • Revision title: command
  • Revision id: 287212
  • Created:
  • Creator: ziyunfei
  • Is current revision? No
  • Comment 25 words added

Revision Content

{{ HTMLVersionHeader(5) }}

Summary

Edit section

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

Usage context

Content categories Flow content, phrasing content
Permitted content None, it is a void element.
Tag omission Must have a start tag, and must not have an end tag.
Permitted parent elements Any element that accepts phrasing content.
Normative document HTML5, section 4.11.3

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.

DOM interface

This element implements the HTMLCommandElement interface.

Examples

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

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() }}

 

{{ languages( { "zh-cn": "zh-cn/HTML/Element/command" } ) }}

Revision Source

<p>{{ HTMLVersionHeader(5) }}</p>
<h2 class="editable" id="Summary"><span>Summary</span></h2>
<div class="editIcon"> <h2 class="editable" id="sect1"><a href="/en/HTML/Element/a#" style="visibility: hidden;" title="Edit section"><span class="icon"><img alt="Edit section" class="sectionedit" src="../../../../skins/common/icons/icon-trans.gif"></span></a></h2>
</div>
<p>The <code>command </code>element represents a command which the user can invoke.</p>
<h2 id="Usage_context">Usage context</h2>
<table class="standard-table"> <tbody> <tr> <td>Content categories</td> <td><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><a href="/en/HTML/Content_categories#form-associated_content" title="en/HTML/Content categories#form-associated content"><br> </a></td> </tr> <tr> <td>Permitted content</td> <td>None, it is a void element.</td> </tr> <tr> <td>Tag omission</td> <td>Must have a start tag, and must not have an end tag.</td> </tr> <tr> <td>Permitted parent elements</td> <td>Any element that accepts <a href="/en/HTML/Content_categories#Phrasing_content" title="https://developer.mozilla.org/en/HTML/Content_categories#Phrasing_content">phrasing content</a>.</td> </tr> <tr> <td>Normative document</td> <td><a class="external" href="http://dev.w3.org/html5/spec/Overview.html#the-command" title="http://dev.w3.org/html5/spec/Overview.html#the-command">HTML5, section 4.11.3</a></td> </tr> </tbody>
</table>
<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="DOM_interface">DOM interface</h2>
<p>This element implements the <code><a href="/en/DOM/HTMLCommandElement" rel="internal">HTMLCommandElement</a></code> interface.</p>
<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="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> </p>
{{ languages( { "zh-cn": "zh-cn/HTML/Element/command" } ) }}
Revert to this revision