Attribute – Autofocus Attribute

Autofocus Attribute | HTML5

The autofocus attribute is a boolean attribute.

When present, it specifies that the element should automatically get input focus when the page loads.

Only one form element in a document can have the autofocus attribute. It cannot be applied to <input type="hidden">.

Applies to



<form> <input type="text" name="fname" autofocus> <input type="text" name="lname"> </form>


This is an HTML5 attribute.

More Information:

HTML autofocus Attribute on

<input> autofocus attribute on MDN web docs

This article needs improvement. You can help improve this article. You can also write similar articles and help the community.