Summary -
In this topic, we described about the <keygen> tag along with detailed example.
The <keygen> element is new in HTML5. Generating a key pair. The <keygen> tag is used for generating a key pair used for forms.
<keygen> tag can be used mostly along with Web-based certificate management systems. When the form is submitted, the private key stored locally and public key sent to server. The tag can be specified like <keygen name=""> with a name in between the quotes of the name attribute.
<keygen> has no data, so end tag not required. <keygen> is not a nested tag.
Syntax -
<keygen>.... HTML text here </keygen>
Optional Attributes -
Attribute | Description | Values |
---|---|---|
autofocus | Specifies the keygen element should get autofocus on page load | None. |
challenge | Specifies the <keygen> element value should be challenged. | Text. |
disabled | Specifies that the form control should be diasabled | None. |
form | Specifies the <keygen> belonging form id | Form_id |
keytype | Specifies the key security algorithm | Rsa (default)Dsaec |
name | Specifies form control name. | Text |
Example -
<!DOCTYPE html>
<html>
<head>
<title>Form example</title>
</head>
<body>
<form action="search-results.htm">
<label>Search: </label>
<input type="text" name="search" >
<label>Encryption: </label> <keygen name="security">
<input type="submit" value="Submit">
</form>
</body>
</html>