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:HTML 5

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.

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

Element
<keygen>YesYesYesYesYes