BBM Tutor
BBM Tutor

HTML5 Tag - <command> Tag

Definition & Uses of HTML5 <command> Tag

The HTML5 <command> tag is new in HTML5

Syntax of HTML5 <command> Tag

<command type="command|checkbox|radio" label="name of the command">

What is HTML5 <command> Tag ?

  • The <command> tag defines a command button that the user can invoke.
  • According to the HTML 5 specification:
  • A command is the abstraction behind menu items, buttons, and links. Once a command is defined, other parts of the interface can refer to the same command, allowing many access points to a single feature to share aspects such as the disabled state.
  • The <command> tag is one of the tags for interactive content in HTML.
  • Since the <command/> tag is a void element, it is not allowed to have any content,
  • The command element is only visible if it is inside a menu element. If not, it will not be displayed, but can be used to specify a keyboard shortcut.

Where to use HTML5 <command> Tag?

  • It can be rendered within a menu (since a menu can have a items that can invoke).
  • It provides an abstraction layer between UI and commands, so that it can possible to make multiple UI elements refer to the same command.
  • This gives 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.
  • The <command> element is meant to be an abstraction to let us refer to the same "command" from multiple menu entries or buttons.

Tips & Notes

  • The <command> tag is currently not supported in any of the major browsers.
  • Internet Explorer 9 (not earlier or later versions), supports the <command> tag.

Simple HTML5 Example #1

<!DOCTYPE HTML>
<html>
<head>
<title> HTML5 <command> - HTML5 Tags Tutor </title>
<script>
function clickme()
{

alert("Hello!! Welcome to BBMINFO Tutor..");
}
</script>
</head>
<body>
<article>
<p>
<command type="command" label="Click Me" onClick="clickme()"/>
<strong>Imp Note: The command tag is only supported in IE 9 browser</strong>
<menu>
<command type="command" label="Click Me" onClick="clickme()"/>
</menu>
</p>
</article>
</body>
</html>

Output Screen

Imp Note: The command tag is only supported in IE 9 browser

Attributes

  • Attributes are the features added to a tag to provide the browser with more information about how the tag should appear or behave.
  • There are 3 type attributes a tag can have. They are Global Attributes, Event Attributes and Element-Specific Attributes.
  • The <command> tag is also capable of supporting the Global Attributes and Event Attributes in HTML5.

Element-Specific Attributes

Attributes

Description

checked ( New )
Indicates whether the command button checked or not.
disabled ( New )
Indicates that command is not available.
icon ( New )
Specifies the URI (or IRI) of graphical image that represents the action.
label ( New )
Specifies the name of the command.
radiogroup ( New )
Specifies the name of the radiogroup the command belongs to.
title ( New )
Specifies the hint describing the command.
type ( New )
Specifies the type of the command

checked

  • This is a boolean attribute, when it present indicates that the command should be checked (pre-selected) when the page loads.
  • If this attribute is present, its value must either be the empty string or a value that is an ASCII case-insensitive match for the attribute's canonical name, with no leading or trailing whitespace (i.e. either checked or checked="checked").
  • This attribute can only be used if type="checkbox" or type="radio".
  • Possible values:
    1. Empty String
    2. checked

disabled

  • This is a boolean attribute. Specifies the disablity of command element.
  • If this attribute is present, its value must either be the empty string or a value that is an ASCII case-insensitive match for the attribute's canonical name, with no leading or trailing whitespace (i.e. either disabled or disabled="disabled").
  • Possible values:
    1. Empty String
    2. disabled

icon

  • Specifies the URI (or IRI) of graphical image that represents the action.
  • The value of this attribute must be a valid non empty URL address|URI reference.
  • Possible values:
    1. An absolute URL of the image.
    2. A relative URL of the image.

label

  • It is a required attribute of Command element. It should be explicitly mentioned and must not be empty.
  • Specifies the a name given to the command for users.
  • Possible values:
    1. Text

radiogroup

  • Specifies the name of the group of commands that will be toggled when the command itself is toggled, for commands whose type attribute has the value "radio".
  • The value of this attribute can be the name of the radiogroup the command belongs to.
  • This attribute must be omitted unless the type attribute is radio.
  • Possible values:
    1. name of the radiogroup| name of the group of commands

title

  • Specifies the hint describing the command, which can be shown to the user.
  • Although title is one of the common attributes, which can be coded on any HTML element, it performs somewhat differently when coded on the command tag.
  • Possible values:
    1. A hint about command

type

  • It specifies the type of the command control.
  • The value of this attribute can be empty which indicates that normal command.
  • Possible keywords for its value:
    1. Empty ( Indicates its default value. )
    2. command ( Indicates a normal command. This is a default value. )
    3. checkbox ( Indicates that the command is usable through checkbox.)
    4. radio ( Indicates that the command is usable through radio.)

Tips & Notes

  • Internet Explorer 9 (not earlier or later versions) supports the type and disabled attributes. However it only supports the "command" type.
  • Other attributes like radiogroup, icon, label, checked attributes are currently not supported in any of the major browsers.

BBM Invoice
 
Disclaimer: Use of this website signifies your agreement to the Terms of Use and Online Privacy Policy.