HTML5 input autofocus Attribute

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>

Try it yourself »


Browser Support

Internet Explorer Firefox Opera Google Chrome Safari

The autofocus attribute is supported in all major browsers, except Internet Explorer.

Leave a comment