Default html form focus without JavaScript

You can do it in HTML5, but otherwise, you must use JavaScript.

HTML5 allows you to add autofocus to your form element, eg:

<input type="text" name="myInput" autofocus />

This does work in browsers which support HTML5 (Or rather, browsers which support this particular part of HTML5) but as you know, not everybody can use it yet.

Leave a Comment