Creating a login and registration page in HTML and CSS is one of the best ways to kick-off your front-end development endeavor. Whether you’re learning about web design, or creating your first front-end project, this simple set of steps will help you create a responsive login form and signup page that is polished and professional, no JavaScript required.
Every site or web app needs a login and registration form system to handle user access and ultimately visitors on the system. From eCommerce sites to social media apps, login and registration forms are necessary for user authentication and for pleasant user experience.
With a solid HTML and CSS framework, you can design a simple but modern user interface (UI) that improves the usability of a website and reinforces their brand.
Step 1: Setting Up the HTML Structure for Login Page
Begin with building the basic HTML structure for our login page.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0"/>
<title>Login Page with Registration Modal</title>
<link rel="stylesheet" href="logreg.css">
</head>
<body>
<div class="form-container">
<form action="home.html">
<h1>Login</h1>
<label for="Username">Username or Email:</label>
<input type="text" id="Username" name="Username"
placeholder="Enter username or email" required>
<label for="password">Password:</label>
<input type="password" id="password" name="password"
placeholder="Enter password" required>
<button type="submit">Login</button>
<p>Don't have an account?
<a onclick="document.getElementById('modal').classList.add('active')">
Register
</a>
</p>
</form>
</div>
</body>
</html>
What Does It All Mean?
Tip: Use semantic HTML as much as possible with proper label and input types. This offers accessibility and helps screen readers understand your form.
Step 2: Creating the Registration Modal
Now we will add the modal popup which contains our registration form.
<div class="modal" id="modal">
<div class="form-container2">
<div class="close-modal">
<a onclick="document.getElementById('modal').classList.remove('active')">
×
</a>
</div>
<form>
<h1>Registration</h1>
<div class="row">
<!-- Form fields will go here -->
</div>
</form>
</div>
</div>
Modal Outline:
Note: The modal is hidden by default (i.e. through CSS) and only appears when the “active class” is added through JavaScript.
Step 3: Adding Registration Form Fields
We will now add fields to the registration form with different input types.
<div class="row">
<div class="half">
<label>👩🏻💼 First Name:</label>
<input type="text" placeholder="Your First Name" required>
</div>
<div class="half">
<label>👩🏻💼 Last Name:</label>
<input type="text" placeholder="Your Last Name" required>
</div>
<div class="half">
<label>📧 Email:</label>
<input type="email" placeholder="Enter Email ID" required>
</div>
<div class="half">
<label>🔒 Password:</label>
<input type="password" placeholder="Enter Password" required>
</div>
<div class="half">
<label>✅ Confirm Password:</label>
<input type="password" placeholder="Confirm Password" required>
</div>
</div>
Key Concepts:
Pro Tip: Make sure to always include a Confirm Password field so users don’t accidentally add a typo when registering.
Step 4: Adding Gender Selection with Radio Buttons
<div class="half">
<label class="gender-label">⚧️ Gender:</label>
<div class="gender-group">
<label><input type="radio" name="gender" value="male" required> Male</label>
<label><input type="radio" name="gender" value="female" required> Female</label>
<label><input type="radio" name="gender" value="other" required> Other</label>
</div>
</div>
How Radio Buttons Work:
Common Mistake: If you do not give related radio buttons the same name, you will be able to select multiple options, which is not intended!
Step 5: Adding Dropdown Selections
<div class="half">
<label>🌍 Countries:</label>
<select required>
<option disabled selected>Select Country</option>
<option value="india">India</option>
<option value="brazil">Brazil</option>
<option value="australia">Australia</option>
<option value="china">China</option>
<option value="france">France</option>
</select>
</div>
<div class="half">
<label>🏛️ State:</label>
<select required>
<option disabled selected>Select State</option>
<option value="gujarat">Gujarat</option>
<option value="kerala">Kerala</option>
<option value="punjab">Punjab</option>
</select>
</div>
Understanding Select Elements:
Note: In a real application, you would use JavaScript/jQuery functionality to populate the state/city options based on the selected country.
Step 6: Adding Advanced Input Types
You will find countless specialized input types that HTML5 uses to make forms more user-friendly:
<div class="half">
<label>🔢 Age:</label>
<input type="number" placeholder="Your Age" required>
</div>
<div class="half">
<label>📞 Phone:</label>
<input type="tel" placeholder="Phone Number" required>
</div>
<div class="half">
<label>🎂 Date of Birth:</label>
<input type="date" required>
</div>
<div class="half">
<label>🕰️ Contact Time:</label>
<input type="time">
</div>
<div class="half">
<label>📝 Resume:</label>
<input type="file">
</div>
<div class="half">
<label>😊 Satisfaction (1–10):</label>
<input type="range" min="1" max="10">
</div>
Input type descriptions:
Pro Tip: HTML5 Input types provide a better experience on mobile because they automatically show the proper keyboards!
Step 7: Adding Terms & Conditions and Submit Button
<div class="checkbox-container">
<input type="checkbox" required>
<label>I agree to the terms & conditions</label>
</div>
<input type="hidden" value="student">
<button type="submit">Register</button>
<p>Already have an account?
<a onclick="document.getElementById('modal').classList.remove('active')">
Login
</a>
</p>
Final Form Elements:
Step 8: Styling the Login Page (CSS)
Now let’s beautify our login page with CSS:
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
body {
font-family: Arial, sans-serif;
background: blue;
min-height: 100vh;
display: flex;
justify-content: center;
align-items: center;
padding: 20px;
}
.form-container {
background: white;
padding: 40px 30px;
border-radius: 8px;
box-shadow: 0 6px 13px rgba(0, 0, 0, 0.3);
width: 350px;
}
CSS Basics:
Step 9: Styling Form Elements
h1 {
text-align: center;
margin-bottom: 20px;
}
label {
display: block;
margin-top: 15px;
font-weight: 500;
}
input, select, textarea {
width: 100%;
padding: 8px;
margin-top: 5px;
border-radius: 6px;
border: 1px solid black;
background-color: #fff6f6;
transition: 0.3s;
}
input:focus, select:focus, textarea:focus {
background-color: #eef7ff;
outline: none;
}
Styling Principles:
Note: You can remove the default outline on focus IF you are providing a visual for the user’s focus (like we are doing with the background color change).
Step 10: Creating the Modal Overlay
.modal {
position: fixed;
top: 0;
left: 0;
width: 100vw;
height: 100vh;
background: rgba(0, 0, 0, 0.9);
display: none;
justify-content: center;
align-items: start;
overflow-y: scroll;
padding: 40px 10px;
z-index: 1000;
}
.modal.active {
display: flex;
}
Modal CSS Explained:
Step 11: Styling the Registration Form Grid
.form-container2 {
background: white;
padding: 40px 30px;
border-radius: 8px;
box-shadow: 0 6px 13px rgba(0, 0, 0, 0.3);
width: 100%;
max-width: 900px;
margin: auto;
}
.row {
display: grid;
grid-template-columns: repeat(3, 1fr);
gap: 20px;
}
.row .half {
width: 100%;
}
CSS Grid Layout:
Pro Tip: Using css grid is best for form layouts since it takes care of spacing and alignment automatically!
Step 12: Making It Responsive
@media (max-width: 900px) {
.row {
grid-template-columns: repeat(2, 1fr);
}
}
@media (max-width: 600px) {
.row {
grid-template-columns: 1fr;
}
}
Responsive Design Principles:
Common Mistake: Forgetting to test on mobile! Always review your forms with different screen sizes.
Step 13: Creating the Welcome/Logout Page
After successful login, user will be redirected to this welcome page:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Welcome To Home Page</title>
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css"
rel="stylesheet" />
<link href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.10.5/font/bootstrap-icons.css"
rel="stylesheet" />
<link rel="stylesheet" href="home.css">
</head>
<body>
<div class="card-container">
<div class="icon-circle">
<i class="bi bi-person-check-fill"></i>
</div>
<h2>Welcome, <span id="username">User</span>👩🏻💼</h2>
<div class="username-box">
You Are Successfully Logged In!
</div>
<a href="log_reg.html">
<button class="logout-btn">
Logout <i class="bi bi-box-arrow-in-right"></i>
</button>
</a>
</div>
</body>
</html>
Welcome Page Structure:
Step 14: Styling the Welcome Page with Glassmorphism
body {
font-family: 'Poppins', sans-serif;
background: linear-gradient(145deg, rgb(5, 5, 111), rgb(19, 130, 167));
min-height: 100vh;
display: flex;
align-items: center;
justify-content: center;
}
.card-container {
background: rgba(255, 255, 255, 0.1);
backdrop-filter: blur(16px);
border-radius: 20px;
padding: 40px;
color: white;
text-align: center;
}
.icon-circle {
background-color: rgba(255, 255, 255, 0.2);
width: 100px;
height: 100px;
border-radius: 50%;
display: flex;
justify-content: center;
align-items: center;
margin: 0 auto 20px;
font-size: 50px;
box-shadow: inset 0 0 10px rgba(255, 255, 255, 0.3);
}
Modern Design Techniques:
Pro Tip: Glassmorphism works best with semi-transparent backgrounds over colorful gradients!
Design Practices:
Pro Tip: Glassmorphism tends to look best with colorful gradients and on a semi-transparent background!
Step 15: Styling the Logout Button
.logout-btn {
background-color: #fff;
color: rgb(6, 6, 162);
font-weight: 600;
border: none;
padding: 12px 28px;
border-radius: 50px;
font-size: 16px;
transition: all 0.3s ease;
box-shadow: 0 5px 20px rgba(255, 255, 255, 0.2);
}
.logout-btn:hover {
transform: translateY(-2px);
box-shadow: 0 7px 25px rgba(255, 255, 255, 0.3);
}
Button Movement:
Login Page Component
The login page is the entry point for our application. It has a basic two-field form (username/email and password), which is contained in a centered container. The main functionality here is the in-line JavaScript in the “Register” link:
onclick=”document.getElementById(‘modal’).classList.add(‘active’)”
This JavaScript code:
Why this method? For simple show/hide functionality, this inline JavaScript is perfectly fine, and for even more complex applications, you would have your JavaScript in its own file.
Registration Modal Component
The modal uses a full screen overlay pattern. While inactive, it has display: none. Once the “active” class is applied:
The close button will work inversely:
onclick=”document.getElementById(‘modal’).classList.remove(‘active’)”
This will remove the “active” class and hide the modal.
Form Validation Flow
HTML5 makes built-in validation possible with some attributes:
required: This field must be filled before they can submit.
type=”email”: Must have @ and domain structure.
type=”number”: Will only accept numeric values.
min/max: Limits for numbers and dates.
Once a user presses “Submit”, the browser will:
Responsive Grid System
The registration form uses CSS Grid with breakpoints:
Desktop (>900px): 3 columns
grid-template-columns: repeat(3, 1fr);
Tablet (600-900px): 2 columns
grid-template-columns: repeat(2, 1fr);
Mobile (<600px): 1 column
grid-template-columns: 1fr;
This guarantees the best layout at any screen size, avoiding horizontal scrolling.
<div class="row">
<div class="half">
<label>👩🏻💼 First Name:</label>
<input type="text" placeholder="Your First Name" required>
</div>
<div class="half">
<label>👩🏻💼 Last Name:</label>
<input type="text" placeholder="Your Last Name" required>
</div>
<div class="half">
<label>📧 Email:</label>
<input type="email" placeholder="Enter Email ID" required>
</div>
<div class="half">
<label>🔒 Password:</label>
<input type="password" placeholder="Enter Password" required>
</div>
<div class="half">
<label>✅ Confirm Password:</label>
<input type="password" placeholder="Confirm Password" required>
</div>
</div>
<div class="half">
<label class="gender-label">⚧️ Gender:</label>
<div class="gender-group">
<label><input type="radio" name="gender" value="male" required> Male</label>
<label><input type="radio" name="gender" value="female" required> Female</label>
<label><input type="radio" name="gender" value="other" required> Other</label>
</div>
</div>
<div class="half">
<label>🔢 Age:</label>
<input type="number" placeholder="Your Age" required>
</div>
<div class="half">
<label>📞 Phone:</label>
<input type="tel" placeholder="Phone Number" required>
</div>
<div class="half">
<label>🎂 Date of Birth:</label>
<input type="date" required>
</div>
<div class="half">
<label>🕰️ Contact Time:</label>
<input type="time">
</div>
<div class="half">
<label>📝 Resume:</label>
<input type="file">
</div>
<div class="half">
<label>😊 Satisfaction (1–10):</label>
<input type="range" min="1" max="10">
</div>
<div class="checkbox-container">
<input type="checkbox" required>
<label>I agree to the terms & conditions</label>
</div>
<input type="hidden" value="student">
<button type="submit">Register</button>
<p>Already have an account?
<a onclick="document.getElementById('modal').classList.remove('active')">
Login
</a>
</p>
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
body {
font-family: Arial, sans-serif;
background: blue;
min-height: 100vh;
display: flex;
justify-content: center;
align-items: center;
padding: 20px;
}
.form-container {
background: white;
padding: 40px 30px;
border-radius: 8px;
box-shadow: 0 6px 13px rgba(0, 0, 0, 0.3);
width: 350px;
}
h1 {
text-align: center;
margin-bottom: 20px;
}
label {
display: block;
margin-top: 15px;
font-weight: 500;
}
input, select, textarea {
width: 100%;
padding: 8px;
margin-top: 5px;
border-radius: 6px;
border: 1px solid black;
background-color: #fff6f6;
transition: 0.3s;
}
input:focus, select:focus, textarea:focus {
background-color: #eef7ff;
outline: none;
}
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Welcome To Home Page</title>
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css"
rel="stylesheet" />
<link href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.10.5/font/bootstrap-icons.css"
rel="stylesheet" />
<link rel="stylesheet" href="home.css">
</head>
<body>
<div class="card-container">
<div class="icon-circle">
<i class="bi bi-person-check-fill"></i>
</div>
<h2>Welcome, <span id="username">User</span>👩🏻💼</h2>
<div class="username-box">
You Are Successfully Logged In!
</div>
<a href="log_reg.html">
<button class="logout-btn">
Logout <i class="bi bi-box-arrow-in-right"></i>
</button>
</a>
</div>
</body>
</html>
A. Components / Keywords Used
Name | Description |
<form> | Container for user input elements that can be submitted |
<input> | Creates interactive fields for user data entry |
<label> | Describes the purpose of an input field for accessibility |
<select> | Creates a dropdown menu with multiple options |
<option> | Individual choices within a select dropdown |
<textarea> | Multi-line text input field for longer content |
<button> | Clickable element that triggers form submission or actions |
type=”text” | Standard single-line text input |
type=”email” | Email input with built-in format validation |
type=”password” | Masked text input for secure password entry |
type=”radio” | Single-selection option button within a group |
type=”checkbox” | Toggle option that can be checked or unchecked |
type=”number” | Numeric input with up/down spinner controls |
type=”date” | Date picker input with calendar interface |
type=”time” | Time selector for hours and minutes |
type=”file” | File upload button for selecting documents |
type=”range” | Slider control for selecting values within a range |
type=”hidden” | Invisible field that stores data for submission |
onclick | JavaScript event that triggers when element is clicked |
classList.add() | JavaScript method to add CSS class to an element |
classList.remove() | JavaScript method to remove CSS class from an element |
required | HTML attribute that makes field mandatory |
placeholder | Hint text displayed inside empty input fields |
.modal | CSS class creating full-screen overlay for popups |
position: fixed | CSS positioning that fixes element relative to viewport |
z-index | CSS property controlling element stacking order |
display: grid | CSS layout system for two-dimensional layouts |
backdrop-filter | CSS property that applies effects to background |
@media | CSS rule for applying styles at specific screen sizes |
B. Key Properties / Parameters / Features
Name | Description |
action | URL where form data is sent upon submission |
name | Identifier for form data when submitted to server |
id | Unique identifier for accessing element via JavaScript |
value | Data associated with form element when submitted |
min / max | Minimum and maximum values for numeric/date inputs |
disabled | Makes element unselectable (used for dropdown placeholders) |
selected | Marks dropdown option as default choice |
accent-color | CSS property that customizes radio/checkbox colors |
box-sizing: border-box | Includes padding and border in element’s width calculation |
flex | CSS display value enabling flexible box layout |
grid-template-columns | Defines number and size of columns in grid layout |
gap | Spacing between grid or flex items |
rgba() | Color format with red, green, blue, and alpha (transparency) |
transition | CSS property for smooth animations between states |
border-radius | CSS property that rounds element corners |
box-shadow | Creates shadow effects to add depth to elements |
backdrop-filter: blur() | Blurs content behind element (glassmorphism effect) |
overflow-y: scroll | Adds vertical scrollbar when content exceeds height |
transform: translateY() | Moves element vertically without affecting layout |
:hover | CSS pseudo-class for styling element when cursor hovers |
:focus | CSS pseudo-class for styling element when selected |
repeat() | CSS grid function for repeating column/row patterns |
1fr | CSS grid unit representing one fraction of available space |
vh / vw | Viewport height/width units (1vh = 1% of viewport height) |
linear-gradient() | Creates gradient background with multiple colors |
Congratulations! You have just built a complete authentication system from scratch. Here is a summary of everything you’ve learned:
Key Takeaways:
1. HTML Forms: You learned how to set up forms that include multiple input types, including text, email, password, radio buttons, checkboxes, dropdowns, file uploads, and specialized inputs, such as date, time, and range sliders.
2. Modal Popups: You built an interactive modal overlay using CSS positioning and JavaScript class manipulation – a pattern used across many high-end websites in the industry.
3. CSS Grid & Flexbox: You implemented the modern CSS layout systems to build responsive multi-column forms that are flexible to every screen size.
4. Form Validation: You used built-in HTML5 validation via the required attribute, and type specific validation, ensuring data integrity without implementing javascript to build a validation routine.
5. Responsive Design: Media queries were used to add breakpoints to organize layouts for desktop, tablet, and mobile devices to improve layout on every screen size.
6. Modern Styling Techniques: You explored modern design patterns like glassmorphism, gradient backgrounds, smooth move transitions and hover states.
7. User Experience: You learned how to indicate visual feedback, via focus states, hover states and success pages – key features in quality web applications.
Expand your knowledge with these excellent resources:
HTML & Forms
CSS Styling
Responsive Design
Practice & Build
Source Code – Complete Login Registration form using Html and CSS:
The login and registration page allows users to create an account (sign up) and log into their account (sign in) securely with their credentials, including emails and password. It is a key aspect of any site that personalizes the user experience or stores user identity.
Yes, you can create and design the frontend (what the user sees) using just HTML and CSS. However, you would need a backend language such as PHP, Node.js, or Python, and a database such as MySQL, to make it functional (such as verifying user's credentials or saving data).
Login Form: Allows existing users to sign in with their credentials.
Registration Form: Allows new users to create an account by providing their name, email, and password.
Both Forms typically have similar input fields but serve different purposes.
Yes! You may add subtle animations to your pages using CSS transitions or keyframes to fade a form in/out, or to animate buttons on hover. This will affect the user's perceptions and provide your page with a modern feel.
Yes, but it requires some work with the backend. You could simply add social-login buttons (such as Google, Facebook, GitHub) with the integration of an API (such as OAuth 2.0). You can style the buttons with CSS on the frontend, which is pretty straightforward and will fit right in the UI.
Copyright © 2025 Niotechone Software Solution Pvt. Ltd. All Rights Reserved.