<command>: The HTML Command element - HTML: HyperText Markup Language 编辑

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 categoriesFlow content, phrasing content, metadata content.
Permitted contentNone, it is an empty element.
Tag omissionThe 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 interfaceHTMLCommandElement

Attributes

This element includes the global attributes.

checked
Indicates whether the command is selected. Must be omitted unless the type attribute is checkboxor radio.
disabled
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 attribute is radio.
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 radio button.

Examples

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

Specifications

SpecificationStatusComment
HTML5
The definition of '<command>' in that specification.
Recommendation

Browser compatibility

BCD tables only load in the browser

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据

词条统计

浏览:71 次

字数:4916

最后编辑:6年前

编辑次数:0 次

    我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
    原文