Welcome to the CodeWithRandom blog!
Today, we are creating a beautiful Login and Signup page using just HTML and CSS. This is a perfect project for beginners to practice front-end skills while making something useful for real projects.
We will design a modern UI with smooth animations, a purple-pink gradient background, and a responsive layout that looks great on both desktop and mobile. The form will have two modes — Sign In and Sign Up — that switch with a sliding animation. We will also add social media icons for possible future logins, like Google or Facebook.
By the end of this tutorial, you will have a ready-to-use authentication form that you can connect to any backend or just use as a static design.
Preview of the Final Output


The final output will have:
- Sign In and Sign Up forms in a single container.
- A sliding panel animation to switch between them.
- Social media login buttons.
- Fully responsive design.
- Branding text “CodeWithRandom”.
Folder Structure
Before we write any code, let’s set up our project folder so everything is organized.

index.html → Our main HTML file.
style.css → All our styling.
app.js → Handles form switching animations.
img/ → Stores our images and icons.
2. HTML Structure
Let’s start with the index.html file.
We will create two forms (Sign In and Sign Up) inside a main .container.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Login & Signup | CodeWithRandom</title>
<link rel="stylesheet" href="style.css" />
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.3/css/all.min.css" />
</head>
<body>
<div class="container">
<div class="forms-container">
<div class="signin-signup">
<!-- Sign In Form -->
<form action="#" class="sign-in-form">
<h2 class="title">Sign in</h2>
<div class="input-field">
<i class="fas fa-user"></i>
<input type="text" placeholder="Username" />
</div>
<div class="input-field">
<i class="fas fa-lock"></i>
<input type="password" placeholder="Password" />
</div>
<input type="submit" value="Login" class="btn solid" />
<p class="social-text">Or Sign in with social platforms</p>
<div class="social-media">
<a href="#" class="social-icon"><i class="fab fa-facebook-f"></i></a>
<a href="#" class="social-icon"><i class="fab fa-twitter"></i></a>
<a href="#" class="social-icon"><i class="fab fa-google"></i></a>
<a href="#" class="social-icon"><i class="fab fa-linkedin-in"></i></a>
</div>
</form>
<!-- Sign Up Form -->
<form action="#" class="sign-up-form">
<h2 class="title">Sign up</h2>
<div class="input-field">
<i class="fas fa-user"></i>
<input type="text" placeholder="Username" />
</div>
<div class="input-field">
<i class="fas fa-envelope"></i>
<input type="email" placeholder="Email" />
</div>
<div class="input-field">
<i class="fas fa-lock"></i>
<input type="password" placeholder="Password" />
</div>
<input type="submit" value="Sign up" class="btn" />
<p class="social-text">Or Sign up with social platforms</p>
<div class="social-media">
<a href="#" class="social-icon"><i class="fab fa-facebook-f"></i></a>
<a href="#" class="social-icon"><i class="fab fa-twitter"></i></a>
<a href="#" class="social-icon"><i class="fab fa-google"></i></a>
<a href="#" class="social-icon"><i class="fab fa-linkedin-in"></i></a>
</div>
</form>
</div>
</div>
<!-- Panels -->
<div class="panels-container">
<div class="panel left-panel">
<div class="content">
<h3>New here?</h3>
<p>Join CodeWithRandom and explore amazing tutorials and projects!</p>
<button class="btn transparent" id="sign-up-btn">Sign up</button>
</div>
<img src="img/log.svg" class="image" alt="" />
</div>
<div class="panel right-panel">
<div class="content">
<h3>One of us?</h3>
<p>Sign in to continue learning and creating with CodeWithRandom!</p>
<button class="btn transparent" id="sign-in-btn">Sign in</button>
</div>
<img src="img/register.svg" class="image" alt="" />
</div>
</div>
</div>
<script src="app.js"></script>
</body>
</html>
HTML Output Preview:

3. CSS Styling
Here’s our style.css.
We’ll use the Poppins font, a gradient background, and rounded input fields.
@import url("https://fonts.googleapis.com/css2?family=Poppins:wght@300;400;500;600;700&display=swap");
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
body, input {
font-family: "Poppins", sans-serif;
}
.container {
position: relative;
width: 100%;
background-color: #fff;
min-height: 100vh;
overflow: hidden;
}
.forms-container {
position: absolute;
width: 100%;
height: 100%;
top: 0;
left: 0;
}
.signin-signup {
position: absolute;
top: 50%;
transform: translate(-50%, -50%);
left: 75%;
width: 50%;
transition: 1s 0.7s ease-in-out;
display: grid;
grid-template-columns: 1fr;
z-index: 5;
}
form {
display: flex;
align-items: center;
justify-content: center;
flex-direction: column;
padding: 0rem 5rem;
transition: all 0.2s 0.7s;
overflow: hidden;
}
form.sign-up-form { opacity: 0; z-index: 1; }
form.sign-in-form { z-index: 2; }
.title {
font-size: 2.2rem;
color: #444;
margin-bottom: 10px;
}
.input-field {
max-width: 380px;
width: 100%;
background-color: #f0f0f0;
margin: 10px 0;
height: 55px;
border-radius: 55px;
display: grid;
grid-template-columns: 15% 85%;
padding: 0 0.4rem;
}
.input-field i {
text-align: center;
line-height: 55px;
color: #acacac;
}
.input-field input {
background: none;
outline: none;
border: none;
font-weight: 600;
font-size: 1.1rem;
color: #333;
}
.btn {
width: 150px;
background-color: #6c63ff;
border: none;
outline: none;
height: 49px;
border-radius: 49px;
color: #fff;
text-transform: uppercase;
font-weight: 600;
cursor: pointer;
}
.btn:hover {
background-color: #5a54d1;
}
.panels-container {
position: absolute;
height: 100%;
width: 100%;
display: grid;
grid-template-columns: repeat(2, 1fr);
}
.container:before {
content: "CodeWithRandom";
position: absolute;
height: 2000px;
width: 2000px;
top: -10%;
right: 48%;
transform: translateY(-50%);
background-image: linear-gradient(-45deg, #6c63ff 0%, #ff6ec4 100%);
color: rgba(255,255,255,0.1);
font-size: 10rem;
text-align: center;
border-radius: 50%;
z-index: 6;
}
.image { width: 100%; }
.panel {
display: flex;
flex-direction: column;
align-items: flex-end;
justify-content: space-around;
text-align: center;
z-index: 6;
}
.left-panel { padding: 3rem 17% 2rem 12%; }
.right-panel { padding: 3rem 12% 2rem 17%; }
.panel h3 {
font-weight: 600;
line-height: 1;
font-size: 1.5rem;
}
With CSS Output Preview:

4. JavaScript for Animation
Our app.js will just handle switching between sign-in and sign-up modes.
const sign_in_btn = document.querySelector("#sign-in-btn");
const sign_up_btn = document.querySelector("#sign-up-btn");
const container = document.querySelector(".container");
sign_up_btn.addEventListener('click', () =>{
container.classList.add("sign-up-mode");
});
sign_in_btn.addEventListener('click', () =>{
container.classList.remove("sign-up-mode");
});5. How It Works
- Default Mode:
- The Sign In form is visible.
- The Sign Up form is hidden with
opacity: 0;.
- When clicking “Sign up”:
- We add the
.sign-up-modeclass to.container. - CSS animations slide the right panel into view and show the sign up form.
- We add the
- When clicking “Sign in”:
- We remove
.sign-up-mode. - The left panel slides back and shows the sign in form.
- We remove
6. Making It Responsive
The included CSS has media queries for 870px and 570px breakpoints so the design works on mobile.
On smaller screens:
- Images shrink or disappear.
- Layout changes from side-by-side to stacked.
- Buttons and text shrink for better fit.
Here Is the Full OutPut Video:
Here Is the Complete Source code Folder: GITHUB
Live Preview: Login Page
How to Create Login and Signup Page Using HTML & CSS — A beginner-friendly step-by-step tutorial by CodeWithRandom.
Thanks for reading our blog — CodeWithRandom
FAQ
Q1: Can I connect this login and signup page to my database?
Yes! This tutorial only covers the front-end part (HTML, CSS, and JS), but you can connect it to a backend like PHP, Node.js, Django, or Firebase to make it fully functional.
Q2: Is this design responsive for mobile devices?
Absolutely. The CSS in this project has media queries to make sure it looks good on desktops, tablets, and mobile phones.
Q3: Can I change the colors and fonts?
Of course! Just edit the style.css file to replace the gradient colors or choose a different Google Font.
Q4: Why did we use Font Awesome icons?
Font Awesome provides ready-made icons that make the form look professional without creating custom images.