This sort of thing used to require more than just HTML to accomplish but with now HTML5 it’s a breeze. Here’s how you can autofocus fields with HTML5 form attributes.
<input autofocus="autofocus" id="username" type="text" />
Yep, it’s that easy. HTML5 form attributes have pretty good browser support and older browsers that don’t support them will simply ignore them.
It can be added in the following ways:
All three do the exact same thing.
HTML5 autofocus has pretty good browser support working in all modern browsers. Not supported in ie9 and below.