Login and Registration Form in HTML and CSS With Source Code
Dear programmers!! In this tutorial, we’ll demonstrate how to make a Login and Registration Form in HTML and CSS With Source Code. A basic understanding of HTML forms is all that is needed for this beginner-level project. We will discuss our project step by step even if you don’t have a concept yet. In this project, you can register and log in on the same form. It is controlled by two different buttons. The login form is displayed when you click the login button. The signup form is opened by clicking the register button. It is turned on thanks to the HTML checkbox. First name, last name, email, password, and other information must be entered on the registration form. Only the email address and password are required to be entered on the login page If you haven’t seen the popup login form that we’ve learned click the link below. I hope you must have got an idea about the project. So, let’s get started on the Signup & Login form Project source codes. First, we’re going to use HTML Code.
Step1: Login And Registration Form In Html Code
Forgot Password? The information for the registration and login forms has been added to the HTML code in the sections below. The codes listed below are copied, and they are then added directly to your HTML file. To start, we’ll add a «login-wrap» class to a div tag, which will wrap our signup and login forms. Now that we have created an input box with the type «radio,» we can use the radio button to switch between the signup and signin forms. We will now create our login form. To do that, we will design a label that requests a username and, beneath it, a text-only input box for the username. We’re going to make a «password» input box now, along with a «checkbox» input box that says «keep me logged in.» Now using hr tag we will make a horizontal rule to which we used to divide our form
Now we will create a forgot password link using the anchor tag. Now we will be creating the structure of our signup form. Using the div tag we will create a container for our singup form. First, we’ll construct a label for our username and an input type for the username called «text.»Then, two input fields of the type «password» will be created. A label asking for the user’s email address will now be created, along with an input box with the type «email» address. we build an input type that serves as a button for signing them up. If the user has already registered on another website, we also create a link for our login page. So we have added the HTML tags and Their contents, Now it’s time to make it attractive by adding the CSS code. Before we can style our page, we must add external styling links to the head section of our html.
Step2: Style Login And Registration Form Using CSS Code
body < margin: 0; color: #6a6f8c; background: #c8c8c8; font: 600 16px/18px "Open Sans", sans-serif; >*, :after, :before < box-sizing: border-box; >.clearfix:after, .clearfix:before < content: ""; display: table; >.clearfix:after < clear: both; display: block; >a < color: inherit; text-decoration: none; >.login-wrap < width: 100%; margin: auto; max-width: 525px; min-height: 670px; position: relative; background: url(https://raw.githubusercontent.com/khadkamhn/day-01-login-form/master/img/bg.jpg) no-repeat center; box-shadow: 0 12px 15px 0 rgba(0, 0, 0, 0.24), 0 17px 50px 0 rgba(0, 0, 0, 0.19); >.login-html < width: 100%; height: 100%; position: absolute; padding: 90px 70px 50px 70px; background: rgba(40, 57, 101, 0.9); >.login-html .sign-in-htm, .login-html .sign-up-htm < top: 0; left: 0; right: 0; bottom: 0; position: absolute; transform: rotateY(180deg); backface-visibility: hidden; transition: all 0.4s linear; >.login-html .sign-in, .login-html .sign-up, .login-form .group .check < display: none; >.login-html .tab, .login-form .group .label, .login-form .group .button < text-transform: uppercase; >.login-html .tab < font-size: 22px; margin-right: 15px; cursor: pointer; padding-bottom: 5px; margin: 0 15px 10px 0; display: inline-block; border-bottom: 2px solid transparent; >.login-html .sign-in:checked + .tab, .login-html .sign-up:checked + .tab < color: #fff; border-color: #1161ee; cursor: pointer; >.login-form < min-height: 345px; position: relative; perspective: 1000px; transform-style: preserve-3d; >.login-form .group < margin-bottom: 15px; >.login-form .group .label, .login-form .group .input, .login-form .group .button < width: 100%; color: #fff; display: block; >.login-form .group .input, .login-form .group .button < border: none; padding: 15px 20px; border-radius: 25px; background: rgba(255, 255, 255, 0.1); >.login-form .group input[data-type="password"] < -webkit-text-security: circle; >.login-form .group .label < color: #aaa; font-size: 12px; >.login-form .group .button < background: #1161ee; cursor: pointer; >.login-form .group .button:hover < background:#1454c4; cursor: pointer; >.login-form .group label .icon < width: 15px; height: 15px; border-radius: 2px; position: relative; display: inline-block; background: rgba(255, 255, 255, 0.1); >.login-form .group label .icon:before, .login-form .group label .icon:after < content: ""; width: 10px; height: 2px; background: #fff; position: absolute; transition: all 0.2s ease-in-out 0s; >.login-form .group label .icon:before < left: 3px; width: 5px; bottom: 6px; transform: scale(0) rotate(0); >.login-form .group label .icon:after < top: 6px; right: 0; transform: scale(0) rotate(0); >.login-form .group .check:checked + label < color: #fff; >.login-form .group .check:checked + label .icon < background: #1161ee; >.login-form .group .check:checked + label .icon:before < transform: scale(1) rotate(45deg); >.login-form .group .check:checked + label .icon:after < transform: scale(1) rotate(-45deg); >.login-html .sign-in:checked + .tab + .sign-up + .tab + .login-form .sign-in-htm < transform: rotate(0); >.login-html .sign-up:checked + .tab + .login-form .sign-up-htm < transform: rotate(0); >.hr < height: 2px; margin: 60px 0 50px 0; background: rgba(255, 255, 255, 0.2); >.foot-lnk
Now that we’ve included our CSS code in our article, let’s go over it step by step. Step1: We’ve now set the margin and padding on our webpage to «zero» using the body tag. «Open Sans» is the family of fonts. «Light Grey» is the backdrop colour setting. The font size was also changed to «dark-grey.» Using the universal selector (*) we will set the box-sizing of our webpage as «border-box». If any of the items overflow, the clearfix attribute will cause them to be automatically set to the height.
body < margin: 0; color: #6a6f8c; background: #c8c8c8; font: 600 16px/18px "Open Sans", sans-serif; >*, :after, :before < box-sizing: border-box; >.clearfix:after, .clearfix:before < content: ""; display: table; >.clearfix:after
Step 2: We will now set its width to «100%» using the (.login-wrap) class. The margin is set to auto, meaning that it will change depending on the content. Additionally, we specified «525 px» for the maximum width and «670 px» for the minimum height. To give our login form a little more flair, we also include a backdrop image. To style our login form, we will use the «.login-html» class. We have set the width to «100%» and the position to absolute. Additionally, we added additional space and made the backdrop of our login form a dark blue color.
Step3: We will set the top, left, right, and bottom space to «zero» and the position to «absolute» using the (.sign-in-htm and.sign-up-htm) files. Our login and signup forms will be rotated 180 degrees by adding some transform properties. We’ll now style the sign-in button. The font size was set to «22 px,» the margin to the right was set to «15 px,» the cursor was set to «pointer,» and the padding to the bottom was set to «5 px.» Additionally, we gave our button a 2-px bottom border. In the similar way we will style our signup form . you will easily understand the code just go through our css code once.
.login-html .tab < font-size: 22px; margin-right: 15px; cursor: pointer; padding-bottom: 5px; margin: 0 15px 10px 0; display: inline-block; border-bottom: 2px solid transparent; >.login-html .sign-in:checked + .tab, .login-html .sign-up:checked + .tab < color: #fff; border-color: #1161ee; cursor: pointer; >.login-form < min-height: 345px; position: relative; perspective: 1000px; transform-style: preserve-3d; >.login-form .group < margin-bottom: 15px; >.login-form .group .label, .login-form .group .input, .login-form .group .button < width: 100%; color: #fff; display: block; >.login-form .group .input, .login-form .group .button < border: none; padding: 15px 20px; border-radius: 25px; background: rgba(255, 255, 255, 0.1); >.login-form .group input[data-type="password"] < -webkit-text-security: circle; >.login-form .group .label < color: #aaa; font-size: 12px; >.login-form .group .button < background: #1161ee; cursor: pointer; >.login-form .group .button:hover < background:#1454c4; cursor: pointer; >.login-form .group label .icon < width: 15px; height: 15px; border-radius: 2px; position: relative; display: inline-block; background: rgba(255, 255, 255, 0.1); >.login-form .group label .icon:before, .login-form .group label .icon:after < content: ""; width: 10px; height: 2px; background: #fff; position: absolute; transition: all 0.2s ease-in-out 0s; >.login-form .group label .icon:before < left: 3px; width: 5px; bottom: 6px; transform: scale(0) rotate(0); >.login-form .group label .icon:after
Step4: Now, we will switch between our sign-in and sign-up forms utilising the checked attribute. Now, utilising the checked property, if we select the signup button, it will display a blue border along the bottom, and if you select signin, the checked property signin form will appear.
.login-form .group .check:checked + label < color: #fff; >.login-form .group .check:checked + label .icon < background: #1161ee; >.login-form .group .check:checked + label .icon:before < transform: scale(1) rotate(45deg); >.login-form .group .check:checked + label .icon:after < transform: scale(1) rotate(-45deg); >.login-html .sign-in:checked + .tab + .sign-up + .tab + .login-form .sign-in-htm < transform: rotate(0); >.login-html .sign-up:checked + .tab + .login-form .sign-up-htm
The project is now finished, we have completed Popup Login form using HTML and CSS. Now look at the live preview. Final Output Login And Registration Form In Html Css: Now We have Successfully created the Login and Registration Form using HTML and CSS . You can use this project directly by copying into your IDE. WE hope you understood the project , If you any doubt feel free to comment!! If you find out this Blog helpful, then make sure to search code with random on google for Front End Projects with Source codes and make sure to Follow the Code with Random Instagram page. follow : codewithrandom
Code by : Arun
How TO — Login Form
Learn how to create a responsive login form with CSS.
Click on the button to open the login form:
How To Create a Login Form
Step 1) Add HTML:
Add an image inside a container and add inputs (with a matching label) for each field. Wrap a element around them to process the input. You can learn more about how to process input in our PHP tutorial.
Example
Step 2) Add CSS:
Example
/* Bordered form */
form border: 3px solid #f1f1f1;
>
/* Full-width inputs */
input[type=text], input[type=password] width: 100%;
padding: 12px 20px;
margin: 8px 0;
display: inline-block;
border: 1px solid #ccc;
box-sizing: border-box;
>
/* Set a style for all buttons */
button background-color: #04AA6D;
color: white;
padding: 14px 20px;
margin: 8px 0;
border: none;
cursor: pointer;
width: 100%;
>
/* Add a hover effect for buttons */
button:hover opacity: 0.8;
>
/* Extra style for the cancel button (red) */
.cancelbtn width: auto;
padding: 10px 18px;
background-color: #f44336;
>
/* Center the avatar image inside this container */
.imgcontainer text-align: center;
margin: 24px 0 12px 0;
>
/* Avatar image */
img.avatar width: 40%;
border-radius: 50%;
>
/* Add padding to containers */
.container padding: 16px;
>
/* The «Forgot password» text */
span.psw float: right;
padding-top: 16px;
>
/* Change styles for span and cancel button on extra small screens */
@media screen and (max-width: 300px) span.psw display: block;
float: none;
>
.cancelbtn width: 100%;
>
>
How To Create a Modal Login Form
Step 1) Add HTML:
Example
Step 2) Add CSS:
Example
/* The Modal (background) */
.modal display: none; /* Hidden by default */
position: fixed; /* Stay in place */
z-index: 1; /* Sit on top */
left: 0;
top: 0;
width: 100%; /* Full width */
height: 100%; /* Full height */
overflow: auto; /* Enable scroll if needed */
background-color: rgb(0,0,0); /* Fallback color */
background-color: rgba(0,0,0,0.4); /* Black w/ opacity */
padding-top: 60px;
>
/* Modal Content/Box */
.modal-content background-color: #fefefe;
margin: 5px auto; /* 15% from the top and centered */
border: 1px solid #888;
width: 80%; /* Could be more or less, depending on screen size */
>
/* The Close Button */
.close /* Position it in the top right corner outside of the modal */
position: absolute;
right: 25px;
top: 0;
color: #000;
font-size: 35px;
font-weight: bold;
>
/* Close button on hover */
.close:hover,
.close:focus color: red;
cursor: pointer;
>
/* Add Zoom Animation */
.animate -webkit-animation: animatezoom 0.6s;
animation: animatezoom 0.6s
>
Tip: You can also use the following javascript to close the modal by clicking outside of the modal content (and not just by using the «x» or «cancel» button to close it):
Example
// When the user clicks anywhere outside of the modal, close it
window.onclick = function(event) if (event.target == modal) modal.style.display = «none»;
>
>
Tip: Go to our HTML Form Tutorial to learn more about HTML Forms.
Tip: Go to our CSS Form Tutorial to learn more about how to style form elements.
Ever heard about W3Schools Spaces? Here you can create your website from scratch or use a template, and host it for free.