HTML <keygen>Tag

This tag is deprecated in the new Web standard.

Alternatives include:

  1. Use the Web Cryptography API to generate keys in JavaScript

  2. Use a dedicated cryptography library


Examples

A form with a keygen field:

<form action="demo_keygen.asp" method="get">
Username: <input type="text" name="usr_name">
Encryption: <keygen name="security">
  <input type="submit">
</form>

Try it Yourself »

Browser Support

Internet Explorer Firefox Opera Google Chrome Safari

Firefox, Opera, Chrome, and Safari 6 support the <keygen> tag.


Tag Definition and Usage

The <keygen> tag specifies a key-pair generator field for forms.

When submitting a form, the private key is stored locally, and the public key is sent to the server.


Differences between HTML 4.01 and HTML5

The <keygen> element is a new tag in HTML5.


Attributes

New: HTML5 new attribute.

Attributes Value Description
autofocusNew autofocus Causes the <keygen> field to get focus when the page loads.
challengeNew challenge If used, the value of the keygen is set to be queried on submission.
disabledNew disabled Disables the <keygen> element field.
formNew form_id Defines one or more forms to which the <keygen> field belongs.
keytypeNew rsa
dsa
ec
Defines the security algorithm of the key.
nameNew name Defines a unique name for the <keygen> element. The name attribute is used to collect the value of the field when the form is submitted.

Global Attributes

The <keygen> tag supports global attributes, view the full attribute tableHTML Global Attributes.


Event Attributes

The <keygen> tag supports allHTML Event Attributes.

Other Extensions