How to set a keygen element that automatically get focused when page loads in HTML5 ?
The <keygen> tag in HTML is used to specify a key-pair generator field in a form. The purpose of this element is to provide a secure way to authenticate users. When a form is submitted then two keys are generated, private key and 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 the future.
<keygen name = "anyname">
If we want a keygen element should automatically get focus when the page loads then we can use the autofocus attribute of <keygen> element. The autofocus attribute is a boolean attribute and when this attribute present, it specifies the <keygen> an element that should automatically get focused when the page loads.
Attention reader! Don’t stop learning now. Get hold of all the important HTML concepts with the Web Design for Beginners | HTML course.