<input autofocus type=text>
Supported Browser Screenshots
Unsupported Browser Screenshots
The Low Down
The first input in source order that has the
autofocus attribute will be focused on page load.
In browsers without
autofocus support, no fields will be focused on
Warning: will scroll the page to that first field. Even within an iframe. So:
know your audience, know the position of the form.
If you use a fallback, make sure to fire it on DOM ready rather than on
window.load. Would be way jarring to have the page position jump after a user
may already be interacting with the page.
Classic example is how successful this idea is for Google.com
(although they don't actually use it - screenshot/march '11).
- Opera 10.53 accepts the attribute but doesn't actually autofocus.
- It's probably good that Mobile WebKit doesn't support this as the zooming/keyboard opening would be too in-your-face in most circumstances.