O'Reilly logo

HTML5 Multimedia Development Cookbook by Lee Jordan, Dale Cruse

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Adding autofocus to form fields

In the past, we have had to rely on JavaScript to add input focus to specific form fields, but not anymore! Now we have the ability to do it natively in HTML5!

How to do it...

Ally Creative at http://allycreative.net/contact effectively uses the autofocus ability in their contact form.

How to do it...

How it works...

Here's how they did it:

<form action="" method="post">
<ol id="left">
<li>
<label for="contact-name" class="label-fade">Jane Doe of ACME Corporation</label>
<input type="text" id="contact-name" name="contact-name" title="Name / Business" autofocus /></li> <li> <label for="contact-mail" class="label- fade">jane.doe@acme.com</label> ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required