Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What exactly is the HTML5 <command> tag and what is the browser support

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

I've tried it out and found that it is not working in Chrome (latest version) and it is working on Safari (even older ones), sorry no FF (don't shoot me please) - Mac only test.

I can't understand what is the use of this element or even if I'm using it correctly.

I thank you in advance for any clarification about it!

like image 455
Trufa Avatar asked Jan 26 '11 01:01

Trufa


People also ask

What is command tag in HTML5?

The command element represents a command that the user can invoke. A command can be part of a context menu or toolbar, using the menu element, or can be put anywhere else in the page, to define a keyboard shortcut.

What is HTML5 and its features?

HTML5 is the next major revision of the HTML standard superseding HTML 4.01, XHTML 1.0, and XHTML 1.1. HTML5 is a standard for structuring and presenting content on the World Wide Web. HTML5 is a cooperation between the World Wide Web Consortium (W3C) and the Web Hypertext Application Technology Working Group (WHATWG).

How many tags are there in HTML5?

Even though there are close to 100 tags in HTML5, you usually only end up using a handful 99% of the time. I am going to teach you 10 HTML tags you need to markup almost all content and anything else you can think of when creating a web page.

What is HTML5 Why was it developed?

HTML 5 is a revision of the Hypertext Markup Language (HTML), the standard programming language for describing the contents and appearance of Web pages. HTML5 was developed to solve compatibility problems that affect the current standard, HTML4.


2 Answers

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.

like image 61
hallvors Avatar answered Sep 22 '22 15:09

hallvors


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

like image 40
RichardTheKiwi Avatar answered Sep 26 '22 15:09

RichardTheKiwi