Skip to content
Related Articles

Related Articles

Improve Article

HTML <keygen> autofocus Attribute

  • Last Updated : 17 Sep, 2021

The HTML <keygen> autofocus Attribute is used to specify that the <keygen> element should get focused when the page loads. It is a boolean attribute.

Note: It supports only the following elements: <button>, <input>, <select> and <textarea>

Syntax:

<keygen autofocus>

Example: Below example illustrates the autofocus attribute of the <keygen> element. 

HTML




<!DOCTYPE html>
<html>
 
<body style="text-align: center;">
    <h1 style="color:green;">
        GeeksforGeeks
    </h1>
 
    <h2>HTML Keygen autofocus attribute</h2>
 
    <form>
        Username: <input type="text" name="uname">
        <br><br> Encryption: <keygen form="myGeeks"
                name="secure" autofocus>
        <input type="submit">
    </form>
</body>
 
</html>

Output:



Supported Browsers:

  • Google Chrome 13.0
  • Opera 11.0
  • Safari 6.0
  • Internet Explorer Not supported
  • Firefox Not supported

Attention reader! Don’t stop learning now. Get hold of all the important HTML concepts with the Web Design for Beginners | HTML  course.

My Personal Notes arrow_drop_up
Recommended Articles
Page :