How to set a keygen element that automatically get focused when page loads in HTML5 ? Last Updated : 06 Jun, 2023 Summarize Comments Improve Suggest changes Share Like Article Like Report 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 is 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. Syntax <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> tag. The autofocus attribute is a boolean attribute and when this attribute is present, it specifies the <keygen> an element that should automatically get focused when the page loads. Syntax: <keygen autofocus> Example: In this example, we will use <keygen> tag HTML <!DOCTYPE html> <html> <body> <form action="mypage.php" method="get"> Username: <input type="text" name="user_name"> Encryption: <keygen name="security" autofocus> <input type="submit"> </form> </body> </html> Output: Comment More infoAdvertise with us Next Article How to focus element while loading the page in HTML ? K kapilnama1998 Follow Improve Article Tags : Web Technologies HTML Web technologies HTML-Tags HTML-Attributes HTML-Questions +2 More Similar Reads How to get focused a button automatically when the page load using HTML ? The <button> tag in HTML is used to define the clickable button. The <button> tag is used to submit the content. The images and text content can use inside <button> tag. The <button> autofocus attribute is used to get focused button automatically after loading the web pages. 1 min read How to set the focus on drop-down list automatically when the page loads in HTML5? The purpose of this article is to focus the drop-down list automatically when the page loads in HTML5. The <select> autofocus attribute is a boolean attribute that specifies that the drop-down list should automatically get focus when the page loads. Syntax: <select autofocus> Example: Th 1 min read How to pre-select an input element when the page loads in HTML5? In this article, we are going to pre-select an input element when the page loads i.e. the user doesn't have to click the first text box to start writing on it. When the page is loaded the input is to be pre-selected and the user can start typing directly. This can be done by using the autofocus attr 1 min read How to focus element while loading the page in HTML ? HyperText Markup Language(HTML) is the basic building block of web pages that defines a structure. This markup language is used by browsers to manipulate data like text, images, and other content so that they can be displayed in the required format. HyperText refers to the links that connect web pag 3 min read How to set a name for keygen element in HTML5 ? In HTML, the <keygen> tag is used to specify a key-pair generator field during a form, and the <keygen> name attribute is used to set the name of the keygen element. The aim of <keygen> element is to supply a secure thanks to authenticate users. When a form is submitted then two ke 2 min read How to set focus on input field automatically on page load in AngularJS ? We can focus on any input field automatically using the angular directives. Here we create a custom directive that can auto-focus on any field in the form. Creating a custom directive is just like creating an Angular component. To create a custom directive we have to replace @Component decorator wit 3 min read Like