过时
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.

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.

<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.

内容类别 流内容 , 措词内容 , metadata content.
准许内容 None, it is an empty element .
Tag omission start tag is mandatory, but, as it is a void element, the use of 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 接口 HTMLCommandElement

属性

此元素包括 全局属性 .

checked
Indicates whether the command is selected. Must be omitted unless the type 属性为 checkbox or radio .
被禁用

Indicates that the command is not available.

icon

Gives a picture which represents the command.

label

The name of the command as shown to the user.

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 属性为 radio .
type
This attribute indicates the kind of command. This can be one of three values.
  • 命令 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()">
					

规范

规范 状态 注释
HTML5
The definition of '<command>' in that specification.
推荐

浏览器兼容性

The compatibility table in this page is generated from structured data. If you'd like to contribute to the data, please check out https://github.com/mdn/browser-compat-data and send us a pull request. 更新 GitHub 上的兼容性数据
桌面 移动
Chrome Edge Firefox Internet Explorer Opera Safari Android webview Chrome for Android Firefox for Android Opera for Android Safari on iOS Samsung Internet
命令 弃用 非标 Chrome 不支持 No Edge 不支持 No Firefox 不支持 No 注意事项
不支持 No 注意事项
注意事项 Before Firefox 24, although not implemented, an object of class HTMLCommandElement was created, instead of the compliant HTMLUnknownElement .
IE 不支持 No Opera 不支持 No Safari 不支持 No WebView Android 不支持 No Chrome Android 不支持 No Firefox Android 不支持 No 注意事项
不支持 No 注意事项
注意事项 Before Firefox 24, although not implemented, an object of class HTMLCommandElement was created, instead of the compliant HTMLUnknownElement .
Opera Android 不支持 No Safari iOS 不支持 No Samsung Internet Android 不支持 No
checked 弃用 非标 Chrome 不支持 No Edge 不支持 No Firefox 不支持 No IE 不支持 No Opera 不支持 No Safari 不支持 No WebView Android 不支持 No Chrome Android 不支持 No Firefox Android 不支持 No Opera Android 不支持 No Safari iOS 不支持 No Samsung Internet Android 不支持 No
被禁用 弃用 非标 Chrome 不支持 No Edge 不支持 No Firefox 不支持 No IE 不支持 No Opera 不支持 No Safari 不支持 No WebView Android 不支持 No Chrome Android 不支持 No Firefox Android 不支持 No Opera Android 不支持 No Safari iOS 不支持 No Samsung Internet Android 不支持 No
icon 弃用 非标 Chrome 不支持 No Edge 不支持 No Firefox 不支持 No IE 不支持 No Opera 不支持 No Safari 不支持 No WebView Android 不支持 No Chrome Android 不支持 No Firefox Android 不支持 No Opera Android 不支持 No Safari iOS 不支持 No Samsung Internet Android 不支持 No
label 弃用 非标 Chrome 不支持 No Edge 不支持 No Firefox 不支持 No IE 不支持 No Opera 不支持 No Safari 不支持 No WebView Android 不支持 No Chrome Android 不支持 No Firefox Android 不支持 No Opera Android 不支持 No Safari iOS 不支持 No Samsung Internet Android 不支持 No
radiogroup 弃用 非标 Chrome 不支持 No Edge 不支持 No Firefox 不支持 No IE 不支持 No Opera 不支持 No Safari 不支持 No WebView Android 不支持 No Chrome Android 不支持 No Firefox Android 不支持 No Opera Android 不支持 No Safari iOS 不支持 No Samsung Internet Android 不支持 No
type 弃用 非标 Chrome 不支持 No Edge 不支持 No Firefox 不支持 No IE 不支持 No Opera 不支持 No Safari 不支持 No WebView Android 不支持 No Chrome Android 不支持 No Firefox Android 不支持 No Opera Android 不支持 No Safari iOS 不支持 No Samsung Internet Android 不支持 No

图例

不支持

不支持

非标。预期跨浏览器支持较差。

非标。预期跨浏览器支持较差。

弃用。不要用于新网站。

弃用。不要用于新网站。

见实现注意事项。

见实现注意事项。

元数据

  • 最后修改: