HTML <keygen> Keygen Tag
Tags: learnhtml, htmlk
Published: 2021-05-10 08:42:29

---
title: HTML <keygen> Keygen Tag
published: true
date: 2021-03-01 06:10:54 UTC
tags: LearnHTML,HTMLK
canonical_url: https://sharepointanchor.com/learn-html/html-keygen-tag/
---

In HTML, the **<keygen> Keygen tag** is used to **generate an encryption key** for passing the encrypted **data to a server**. It is one of the **new sectioning elements in HTML 5**. The main purpose of the **<kegen>** element is to **provide a secure way** to authenticate users.

When an HTML [< **form>**](http://<form>) is submitted, the **browser will generate two keys**. One is a private key and another one is a public key. The **private key** stored **locally** , and the **public key** is **sent to the server**. The public key is used to **generate a client certificate to authenticate the user** for future purposes.

<svg aria-hidden="true" focusable="false" data-icon="clock" width="20" height="20" fill="none" stroke="currentColor" style="display:inline-block;vertical-align:-0.1em" role="img" xmlns="http://www.w3.org/2000/svg" viewbox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 8v4l3 3m6-3a9 9 0 11-18 0 9 9 0 0118 0z"></path></svg>Estimated reading time: 3 minutes

## Syntax:

The <kegen> tag **doesn’t require the closing tag** in **HTML**. But in **XHTML** it contains both the **opening <keygen> tag** and **closing <keygen/> tag**.

```

<keygen name= "name">

```

### HTML <keygen> Tag Characteristics:
<style> th, td{ padding: 20px; } </style>

| HTML <keygen> tag | This tag specifies a key-pair generator field used for forms |
| Content categories | Flow content, Phrasing content, interactive content, listed, labelable, submittable, resettable form-associated element, palpable content. |
| Permitted content | None. It is an empty element. |
| Tag omission | Must have a start tag and end tag is not required. |
| Permitted parents | Any HTML element that accepts phrasing content. |
| Permitted ARIA roles | None |
| DOM interface | HTMLKeygenElement |

## Sample of the HTML <keygen> Tag:

```

<!DOCTYPE html>
<html>
  <head>
    <title>HTML <keygen> Tag</title>
  </head>
  <body>
<h2>Example of the HTML <keygen> Tag</h2>
    <form action="/form/submit" method="get">
      <keygen name="rsaPublicKey" keytype="RSA">
        User Name:
        <input type="text" name="usr_name">
        <input type="submit">
    </form>
  </body>
</html>

```

**Note** : The functionality of **<keygen>** the element in HTML **depended on the web browser** and the corresponding web server program.

## Result:

![](https://sharepointanchor.com/wp-content/uploads/2021/02/result-47.png)<figcaption>Result</figcaption>

### Download Sample File:

[HTML-keygen-tag](https://sharepointanchor.com/wp-content/uploads/2021/02/HTML-keygen-tag.html)[Download](https://sharepointanchor.com/wp-content/uploads/2021/02/HTML-keygen-tag.html)

## Attributes:

The **HTML keygen tag** supports both the **Global Attributes** and **Event Attributes**.

<style> th, td{ padding: 20px; } </style>

| Attribute | Value | Description |
| --- | --- | --- |
| autofocus | autofocus | This attribute is used to **define the loading of the page the element must automatically receive a focus**. **Not supported in Internet Explorer and Firefox.** |
| challenge | challenge | It defines the **call string** , that is **passed along with the public key**. The attribute value is any text string. If the attribute isn’t specified, the default is an empty string. |
| disabled | disabled | This indicates that the **<keygen> element must be disabled**. |
| form | form\_id | The form element will help to **indicate the identifier of the form** or forms to which the **<keygen>** element belongs. **Not supported in Internet Explorer.** |
| keytype | | It defines the **key-encryption algorithm**. |
| rsa | From the key type attribute, the user can choose **between high and medium security** (the default value). |
| dsa | Used to **select the key size**. |
| ec | The user can choose between **high and medium security**. **Not supported in Internet Explorer and Safari.** |
| name | name | Helps to **define the name of the <keygen> element**. |

## Browser Support:

![](https://sharepointanchor.com/wp-content/uploads/2021/02/browsre.png)<figcaption>Result</figcaption>

### Related Articles:

- **[HTML <form> Form Tag](https://sharepointanchor.com/learn-html/html-form-tag/)**
- **[HTML <datalist> Data List Tag](https://sharepointanchor.com/learn-html/html-datalist-data-list-tag/)**
- [**Basic HTML Definitions and Usages in the Real World**](https://sharepointanchor.com/learn-html/basic-html-definitions-and-usages-in-real-world/)
- **[HTML <applet> Applet Tag](https://sharepointanchor.com/learn-html/html-applet-tag/)**
- **[HTML <html> Tag](https://sharepointanchor.com/learn-html/html-tag/)**

The post [HTML <code><keygen></code> Keygen Tag](https://sharepointanchor.com/learn-html/html-keygen-tag/) appeared first on [Share Point Anchor](https://sharepointanchor.com).