Skip to content
Tutorials Center
My learning

Topics

HTML Reference ยท Obsolete Elements

The <keygen> element (obsolete)

The HTML <keygen> element generated key pairs in forms for client certificates. Learn why browsers removed it and what to use today, such as the Web Crypto API.

The <keygen> element was a form control that generated a public/private key pair in the browser. When the form was submitted, the public key was sent to the server, which typically used it to issue a client certificate, while the private key stayed in the browser's key store. It showed up as a drop-down of key strengths.

Why it's obsolete

Only some browsers ever implemented it, and never consistently: Internet Explorer and Edge never supported it. Its design relied on old cryptography and gave sites little control, and it mixed certificate management into ordinary forms. Browsers removed it around 2017 (Chrome) and 2019 (Firefox), and the HTML standard dropped it.

Current browsers treat <keygen> as an unknown element: no control appears and nothing is submitted.

Modern replacement

For cryptography in the page, use the Web Crypto API (crypto.subtle). For passwordless sign-in with keys held by the device, use WebAuthn (passkeys). Certificate enrollment is now handled by operating system or enterprise tools.

HTML
<!-- Before: obsolete, ignored by browsers -->
<form action="/enroll" method="post">
  <keygen name="pubkey" keytype="rsa">
  <button>Request certificate</button>
</form>
After: a key pair with the Web Crypto API

crypto.subtle is only available in secure contexts (pages served over HTTPS or from localhost), so the example reports that limit if the preview isn't one.

Technical summary

Status Obsolete; removed from the standard and from browsers
Replacement Web Crypto API (crypto.subtle), WebAuthn
Still rendered by browsers No