Command Tag in HTML5

In this article I am going to describe about the implementation and use of Command Tag in HTML5.
  • 1452

Command Tag

The <command> tag specifies a command (a radiobutton, a checkbox, or a command button) that the user can call or execute.

<command> Tag is introduced in HTML5.

It must have a start tag. And should not have an end tag.The command element cannot contain 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.

Note : If you disable the command element using:

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

In disabling the command element using above code, it would disable all the controls referring to this command element.
 

Browser Support

The <command> tag is currently only supported by Internet Explorer 9. While all other browsers doesnot support the command tag.

How to Use Command Tag in HTML5

Syntax of command tag is shown below

<command type="command | empty | radio | checkbox" label="name" icon="image" HTMLEvent="JavaScript_Function_Name">

Attributes

   Attributes      Value                                                  Description
   checked    checked Defines if the command is checked or not. Use only if type is radio or checkbox.
   disabled    disabled Defines if the command is available or not.
   icon    URL Defines the url of an image to display as the command.
   label    text Defines a name for the command. The label is visible
   radiogroup    groupname Defines the name of the radiogroup this command belongs to. Use only if type is radio 
   type    command

   checkbox

    radio

Defines the type of command. Default value is command

Example of Command Tag in HTML5

<!DOCTYPE html>

 

<html lang="en" xmlns="http://www.w3.org/1999/xhtml">

<head>

    <meta charset="utf-8" />

    <title>Command Tag</title>

    <script>

        function run()

        {

            alert("Hello World");

        }

    </script>

</head>

<body>

    <h3>Implementation of Command Tag in HTML5</h3>

    <menu>

        <command type="command" label="Run" onclick="run()">Run</command>

    </menu>

    <input type="button" command="Run" value="Run Form" />

    <p><b>Note:</b> The &lt;command&gt; tag is currently only supported in IE9.</p>

</body>

</html>

 

Output

 command.jpg

© 2020 DotNetHeaven. All rights reserved.