In this example below you will see how to do a autofocus with some HTML / CSS and Javascript

This awesome code was written by iamdavidobrien, you can see more from this user in the personal repository.
You can find the original code on
Copyright iamdavidobrien ©


  • HTML
  • JavaScript
<!DOCTYPE html>
<html lang="en" >

  <meta charset="UTF-8">


		<title>My form demo</title>
	    <link rel="stylesheet" href="">

		<h1>Heading level one</h1>
		<nav class="menu">
		    <li><a href="#">Home</a></li>
		    <li><a href="#">About</a></li>
		    <li><a href="#">Contact</a></li>
			<form action="#">
				<fieldset class="email">
					<label for="email">Enter your email address</label>
					<input id="email" type="email" autofocus>
					<button class="go">Go</button>
				<fieldset class="password">
					<input id="password" type="password" aria-labelledby="pwhelp" placeholder="Type your password">
					<p id="pwhelp">Welcome, David. You already have an account with us. Enter your password to continue.</p>
					<button class="signin">Sign in</button>
		<script src=""></script>
		<script src="" integrity="sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa" crossorigin="anonymous"></script>

  <script src=''></script>


    <script  src="js/index.js"></script>



/*Downloaded from */
			$( document ).ready(function() {
					$('#password').attr('autofocus', true);