HTML5 introduced an autofocus attribute on all web form controls. The autofocus attribute sets focus on the field that has been given the attribute as soon as the page loads. Doing this allows the user to begin typing immediately.
To include autofocus in your form you just need to add the
autofocus attribute to you input field and it will give you the desired effect.
<form> <input name="s" autofocus> <input type="submit" value="Search"> </form>
The above renders this:
If the browser doesn’t support the autofocus attribute, it will be ignored. So start using it today!