What exactly is the HTML5 tag and what is the browser support

前端 未结 5 1563
有刺的猬
有刺的猬 2020-12-10 11:26

I\'ve read the HTML5 spec for and found the information on this element very vague.

I\'ve tried it out and found that it is not work

相关标签:
5条回答
  • 2020-12-10 11:36

    The lists.whatwg.org link went dead - the related discussion can be found on:

    http://lists.w3.org/Archives/Public/public-whatwg-archive/2012Dec/0264.html

    Subject "[whatwg] and friends", From: Ian Hickson , Date: Sat, 29 Dec 2012 01:23:20 +0000 (UTC)

    0 讨论(0)
  • 2020-12-10 11:37

    It works on Firefox 3.6.13 from Windows by the way.

    The command element is meant to encapsulate something that you can do. It can be rendered within a menu (since a menu presents items you can invoke).

    The idea

    It provides an abstraction layer between UI and commands, so that you can make multiple UI elements refer to the same command. This gives you the flexibility of having one command element, rendered in a menu, that is also invoked via a URL in the middle of the page as well as a button at the bottom of the page. Disabling the command disables all access paths (url/button/menu) to the action behind the command.

    Where we are at - as of 26 Jan 2010

    There is currently very scarce information as to how linking it to multiple elements will actually work (since browsers have only just started implementing it!) but that is one of its intentions.

    At the present moment, the only documented usage is to provide a semantically unique tag to specify (without using <input> or <button> elements) that it is a command within a <menu>, thereby allowing "real" menu rendering by the browser (when implemented).

    0 讨论(0)
  • 2020-12-10 11:43

    The <command> element is meant to be an abstraction to let you refer to the same "command" from multiple menu entries or buttons. AFAIK the idea is something like

    <command id="doThat" onclick="doThat()"></command>
    <input type="button" command="doThat" value="click me to do that">
    <menu command="doThat">This does that too</menu>
    

    Then, if you want to indicate that the user can not do that in the context, you could do

    document.getElementById('doThat').disabled=true;
    

    and both the button and the menu entry would become disabled. Or you could assign a shortcut key to the command element, and either menu and button would respond to the shortcut. Things like that.

    I'm not sure but I think this part of HTML5 is unfinished and likely will be removed before HTML5 is released as a final specification? As-is, it is indeed unclear how it is intended to work.

    0 讨论(0)
  • 2020-12-10 11:46

    User-agents define the <a /> tag as interactive, but this element was only designed to make an hypertext reference without any idea of click.

    This user-agent behavior became a standard, which is not the same with the longdesc attribute of the <img /> tag.

    Because HTML was designed to structure information and contents, not to make interactions, the new version of HTML (5) tries to "palliate" this lack and introduces the <command /> tag to have interactions on HTML non-informative contents as "read more" anchors in example.

    Note that "A command can be explicitly part of a context menu or toolbar" should also say that the <command /> can be used in another context and does not require <form /> tag instead of <input /> or <button />.

    Thank you to Spontifixus & Daniel Kutik for correcting this answer

    0 讨论(0)
  • 2020-12-10 11:48

    command has been removed in favor of menuitem. Further info:

    • http://lists.whatwg.org/pipermail/whatwg-whatwg.org/2012-December/038472.html
    • http://www.whatwg.org/specs/web-apps/current-work/multipage/interactive-elements.html#the-menu-element
    0 讨论(0)
提交回复
热议问题