HTML <keygen> tag

Updated: 05/08/2017 by Computer Hope

HTML keygen tagWhen writing in HTML, the <keygen> tag is used to designate 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, as well as related attributes and browser compatibility.

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

Example code

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

Example result

Username:
Encryption:

Attributes

Within an HTML tag, an attribute dictates certain aspects of an HTML element. Attributes are made up of a name and value pair; all tags support standard attributes. The following table shows all of the current unique HTML attributes for the <keygen> tag, as well as a description of each.

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) an <keygen> element belongs to
keytype Designates the security algorithm to be used with the key
name Designates a name for the <keygen> element

Compatibility

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

Additional form elements

Algorithm, Browser, Compatibility, Nesting, URL