HTML <keygen> tag

Updated: 09/12/2023 by Computer Hope
HTML keygen tag

When writing in HTML (hypertext markup language), the <keygen> tag designates a key-pair generator field used within <form> tags. Upon submission, the public key is sent to the server while the private key is stored locally. They are useful for adding security to forms. The following sections contain information about the <keygen> tag, including an example of it in use, and related attributes and browser compatibility.

Note

The <keygen> tag belongs to a group of tags called form elements.

Example of <keygen> code

<form>
Username: <input type="text" name="uname"><br>
Encryption: <keygen name="secure">
<input type="submit">
</form>

Example result

Username:
Encryption:

Attributes

All HTML tags support standard attributes that define the settings of an HTML element. In addition to the standard settings, the <keygen> tag has the following unique attributes.

Attribute Description
autofocus Designates that an <keygen> element should be the first thing focused when the page loads.
challenge Designates that the value of the <keygen> element should be double checked upon submission.
disabled Designates that the <keygen> element is disabled.
form Designates the form(s) containing the <keygen> element.
keytype Designates the security algorithm to be used with the key.
name Designates a name for the <keygen> element.

Compatibility

Edge Internet Explorer Firefox Safari Opera Chrome
All versions Not supported 1.0+ 1.2+ 3.0+ 1.0+

Additional form elements

Algorithm, Browser, Compatibility, Nesting, URL, Web design terms