How to Make Login and Registration Form using HTML and CSS
In this tutorial, we learn how to make Login and Registration Form using HTML and CSS?
I hope you will see, login and Registration form on multiple websites, if you have not seen both form together, then I am sure separated form you have seen on mostly website.
Therefore in this program I will create form together, this form works on the toggle when you click on the login form, then opened login section, and when you click on Register button then opened Register section.
therefore, In the HTML, we will put both forms, such as login form and Registration form, hiding the second one with CSS, there is no need to use JavaScript, you can handle both form with pure CSS.
I have used social icons images such as Facebook, Twitter, etc. here you can use google font-awesome icons, in the previous tutorial I have discussed how to use font-awesome icons.
so, in this tutorial, we create two HTML forms that will switch between registration and login using the CSS properties. the idea behind to create the Login and Registration Form is to show the user the login form and provide a link to “switch” to the registration form.
therefore, you can say that you will learn dual design program, or dual design split form with together, this sample design used in your website.
it is also possible to add or edit or field in those form, it will help you to save time for design form or Registration form in your project.
if you want to view the demo then click on the view demo button, I hope you will enjoy this program.
Explanation of Source Code for Login and Registration Form used HTML and CSS
Let’s discuss the source code which I have used to create this program, First I have created them class="main"
and put the element inside the “Main” div. this div have width:100%; height:100%;
therefore after that I have created a class=”form-box” and put all the elements inside the .form-box, to create a form-box used CSS properties such as width, height, position, margin, background, padding, overflow, etc.
after that create a class=”button-box”, inside the button-box I have to take two toggle button, one for login and another for Register button. which both buttons look like this:
1 2 |
<button type="button" class="toggle-btn" onclick="login()">Login</button> <button type="button" class="toggle-btn" onclick="register()">Register</button> |
this toggle button works on the click event such as onclick=" login()"
and onclick="register()"
and for the social icons, I have used social Icons images, for the display social icons images I create class="social-icons"
and use few CSS properties such as width, box-shadow, cursor, border-radius, etc.
therefore, I have used ID’s for both form, one id for login form and second id for register form such as <form id="login" class="input-group">
and <form id="register" class="input-group">
. these two forms open on click of toggle button and both forms fetch with the separated ID on the click on the toggle button.
furthermore, inside the login form, I have take two input field such as Used Id and Password and taken one checkbox, when inside the register form I have taken three input field such as User Id, Email Id, Password and also one checkbox for term and conditions.
therefore, I have used two buttons one button for Login and a second button for register. these are the whole concept which I have used to design both forms together.
here everything can not explain in writing. I hope you can understand, when you get the source code you can analyze all the code segment which I have used.
you have to need to create two files for making this program, one file for HTML and second file for CSS. Follow all the step to make the program.
First Step: Create HTML File as Name “index.html” | Change fileName as you want
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
<!DOCTYPE html> <html> <head> <title>Login and Registraion form</title> <link rel="stylesheet" href="css/stylesheet.css"> </head> <body> <div class="Main"> <div class="form-box"> <div class="button-box"> <div id="btn"></div> <button type="button" class="toggle-btn" onclick="login()">Login</button> <button type="button" class="toggle-btn" onclick="register()">Register</button> </div> <div class="social-icons"> <img src="img/fb.png"> <img src="img/in.png"> <img src="img/tw.png"> </div> <form id="login" class="input-group"> <input type="text" class="input-field" placeholder="User Id" required> <input type="text" class="input-field" placeholder="Enter-Password" required> <input type="checkbox" class="check-box"><span>remember password</span> <button type="submit" class="submit-btn">Login In</button> </form> <form id="register" class="input-group"> <input type="text" class="input-field" placeholder="User Id" required> <input type="email" class="input-field" placeholder="Email Id" required> <input type="text" class="input-field" placeholder="Enter password" required> <input type="checkbox" class="check-box"><span>I Agree to The Term & Condition</span> <button type="submit" class="submit-btn">Register</button> </form> </div> </div> <script type="text/javascript" src="js/functions.js"></script> </body> </html> |
Second Step: Create CSS file as Name “stylesheet.css” | Change FileName as you want
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 |
*{ margin: 0px; padding: 0px; font-family: sans-serif; } body{ background-color: #ccc; } .Main{ height: 100%; width: 100%; position: absolute; } .form-box{ width: 380px; height: 480px; position: relative; margin: 6% auto; background: #fff; padding: 5px; overflow: hidden; } .button-box{ width: 220px; margin: 35px auto; position: relative; box-shadow: 0 0 20px 9px #33ffcc1f; border-radius: 30px; } .toggle-btn{ padding: 10px 30px; cursor: pointer; background: transparent; border:0; outline: none; position: relative; } #btn{ top: 0; left: 0; position: absolute; width: 110px; height: 100%; background: linear-gradient(to bottom, #33ccff 0%, #66ff33 100%); border-radius: 30px; transition: .5s; } .social-icons{ margin: 30px auto; text-align: center; } .social-icons img{ width: 30px; margin: 0 12px; box-shadow: 0 0 20px 0 #7f7f7f3d; cursor: pointer; border-radius: 50%; } .input-group{ top: 180px; position: absolute; width: 280px; transition: .5s; } .input-field{ width: 100%; padding: 10px 0; margin: 5px 0; border-left: 0; border-top: 0; border-right: 0; border-bottom: 1px solid #999; outline: none; background: transparent; } .submit-btn{ width: 85%; padding: 10px 30px; cursor: pointer; display: block; margin: auto; background: linear-gradient(to bottom, #33ccff 0%, #66ff33 100%); border:0; outline: none; border-radius: 30px; } .check-box{ margin: 30px 10px 30px 0; } span{ color: #777; font-size: 12px; bottom: 68px; position: absolute; } #login{ left: 50px; } #register{ left: 450px; } |
you have to face any trouble then comment me down below. I will try to resolve the problem as soon as possible. thanks for viewing these post.