revision:
It is used to specify that the element should get focus when the page loads.
It supports only the following elements: <button>, <input>, <select> and <textarea>.
Only one form-associated element in a document can have this attribute specified. If there are several, the first element with the attribute set inserted, usually the first such element on the page, get the initial focus.
<elementName autofocus>
You can't apply autofocus on inputs of type "hidden", because hidden inputs can't be focused. Also, autofocus can only be on one element on one page. So don't use it on multiple elements.
<form style="margin-left:5vw;"> <label for="fname">First name:</label> <input type="text" id="fname" name="fname" autofocus><br> <label for="lname">Last name:</label> <input type="text" id="lname" name="lname"><br> <input type="submit"> </form>
The button autofocus attribute
<p style="margin-left:5vw;">The button autofocus attribute</p> <button style="margin-left:5vw;" type="button" autofocus onclick="alert('Hello world!')">click me!</button>