Place autofocus in the text box when a page gets loaded without JavaScript support in HTML?


The autofocus attribute is a boolean attribute. When present, it specifies that an <input> element should automatically get focus when the page loads. An example is given below

<!DOCTYPE html>
<html>
   <body>
      <form action = "/new.php">
         First Name: <input type = "text" name = "fname" autofocus><br>
         Last Name: <input type = "text" name = "lname"><br>
         <input type="submit">
      </form>
   </body>
</html>

Updated on: 04-Jun-2020

99 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements