Usage of autofocus HTML5 attribute



HTML5 introduced a new attribute called autofocus that would be used as follows:

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

This attribute is supported by latest versions of Mozilla, Safari and Chrome browsers only.

Example

You can try to run the following code to learn how to work with autofocus attribute:

<!DOCTYPE HTML>
<html>
   <body>
      <form action = "/cgi-bin/html5.cgi" method = "get">
         Enter email : <input type = "text" name = "newinput" autofocus/>
         <p>Try to submit using Submit button</p>
         <input type = "submit" value = "submit" />
      </form>
   </body>
</html>
karthikeya Boyini
karthikeya Boyini

I love programming (: That's all I know


Advertisements