Example
Let the “First name” input field automatically get focus when the page loads:
<form action=”demo_form.asp”>
First name:<input type=”text” name=”fname” autofocus=”autofocus” /><br />
Last name: <input type=”text” name=”lname” /><br />
<input type=”submit” />
</form>
First name:<input type=”text” name=”fname” autofocus=”autofocus” /><br />
Last name: <input type=”text” name=”lname” /><br />
<input type=”submit” />
</form>
Browser Support
The autofocus attribute is supported in all major browsers, except Internet Explorer.