HTML <keygen> tag

Updated: 11/13/2018 by Computer Hope
HTML keygen tag

When 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, and related attributes and browser compatibility.


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

Example of <keygen> code

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

Example result



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


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