HTML Tags
Advertisements

HTML5 <keygen> Tag

Topic: HTML5 Tags ReferencePrev|Next

Description

The <keygen> element generates an encryption key for passing encrypted data to a server. When an HTML form is submitted, the browser will generate a key pair and store the private key in the browser's local key storage and send the public key to the server.

The following table summarizes the usages context and the version history of this tag.

Placement: Inline
Content: None. It is an empty element.
Start/End Tag: Start tag: required, End tag: forbidden
Version: New in HTML5

Syntax

The basic syntax of the <keygen> tag is given with:

HTML: <keygen>; XHTML: <keygen />

The example below shows the <keygen> tag in action.

<form action="process-key.php" method="post">
    <label>Username: <input type="text" name="username"></label>
    <label>Encryption: <keygen name="key"></label>
    <input type="submit" value="Submit">
</form>

Tag-Specific Attributes

The following table shows the attributes that are specific to the <keygen> tag.

Attribute Value Description
autofocus autofocus This Boolean attribute specifies that a keygen element should automatically get focus when the page loads.
challenge challenge Specifies a challenge string that is submitted along with the public key. The default value is an empty string, if not specified.
disabled disabled This Boolean attribute indicates that the keygen form control disabled for interaction.
form form-id Specifies the <form> element that the <keygen> element is associated with (its form owner).
keytype rsa
dsa
ec
Specifies the type of key generated. The default value is rsa.
name name Defines a name for the keygen element, which is submitted with the form data.

Global Attributes

Like all other HTML tags, the <keygen> tag supports the global attributes in HTML5.


Event Attributes

The <keygen> tag also supports the event attributes in HTML5.


Browser Compatibility

The <keygen> tag is supported in all major modern browsers.

Browsers Icon

Basic Support—

  • Firefox 1+
  • Google Chrome 1+
  • Internet Explorer ×
  • Apple Safari 1.2+
  • Opera 3+

Further Reading

See tutorial on: HTML Forms.

Related tags: <form>, <label>.

Advertisements
Bootstrap UI Design Templates Property Marvels - A Leading Real Estate Portal for Premium Properties