HTML <keygen> autofocusAttribute
Example
Make the "Encryption" field automatically get focus when the page loads:
<form action="demo_keygen.html" method="get">
Username: <input type="text" name="usr_name">
Encryption: <keygen name="security" autofocus>
<input type="submit">
</form>
Try it Yourself »
Browser Support
![]()
![]()
![]()
![]()
![]()
Opera, Chrome, and Safari 6 support the autofocus attribute of the <keygen> tag.
Definition and Usage
The autofocus attribute is a boolean attribute.
The autofocus attribute specifies that the <keygen> element will automatically get focus when the page loads.
Differences between HTML 4.01 and HTML5
The <keygen> tag is new in HTML5.
Differences between HTML and XHTML
In XHTML, attribute minimization is forbidden, and the autofocus attribute must be defined as <keygen autofocus="autofocus" />.
Syntax
<keygen autofocus>
HTML <keygen> Tag Other Extensions