Modern CSS Login Form UI Design Tutorial for Beginners

By Vandu
May 24, 2025

Follow us on


Learn how to create a stylish and responsive login form using modern CSS. This step-by-step tutorial is perfect for beginners who want to build a clean and professional-looking login UI.

Modern CSS Login Form UI Design Tutorial for BeginnersCreate a Login Form UI with Modern Styling in CSS

A login form is one of the most essential components of any website or web application. In this tutorial, we will create a modern-looking login form using HTML and CSS, and explain each line of code in a simple, beginner-friendly way.

Let’s build a beautiful and clean UI form that you can use in your projects!


🎯 What Will You Learn?

  • How to structure a login form using HTML.

  • How to style it using modern CSS techniques.

  • How to center the form on the screen.

  • How to add hover effects and responsive design.


🧱 Step 1: HTML Structure

Let’s start by writing the basic HTML for our login form.

🔸 HTML Code

<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8" />
  <meta name="viewport" content="width=device-width, initial-scale=1.0" />
  <title>Modern Login Form</title>
  <link rel="stylesheet" href="style.css" />
</head>
<body>
  <div class="login-container">
    <form class="login-form">
      <h2>Login</h2>
      <div class="input-group">
        <label for="username">Username</label>
        <input type="text" id="username" placeholder="Enter your username" required />
      </div>
      <div class="input-group">
        <label for="password">Password</label>
        <input type="password" id="password" placeholder="Enter your password" required />
      </div>
      <button type="submit">Login</button>
    </form>
  </div>
</body>
</html>
 

🔍 HTML Explanation

  • <!DOCTYPE html>: Declares the document as HTML5.

  • <meta> tags: Set character encoding and mobile responsiveness.

  • <div class="login-container">: A wrapper for our form.

  • <form class="login-form">: The actual login form.

  • <h2>: Heading for the form.

  • label and input: For username and password fields.

  • <button>: Submits the form.


🎨 Step 2: CSS Styling

Now let’s style the login form to make it look modern and professional.

🔸 CSS Code (style.css)

/* Reset default margin and padding */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  font-family: 'Segoe UI', sans-serif;
}

/* Full screen background with center alignment */
body {
  height: 100vh;
  background: linear-gradient(to right, #6a11cb, #2575fc);
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Container for the form */
.login-container {
  background: white;
  padding: 40px 30px;
  border-radius: 12px;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.2);
  width: 100%;
  max-width: 400px;
}

/* Form heading */
.login-form h2 {
  text-align: center;
  margin-bottom: 20px;
  color: #333;
}

/* Input group */
.input-group {
  margin-bottom: 20px;
}

/* Labels */
.input-group label {
  display: block;
  margin-bottom: 6px;
  color: #555;
  font-weight: 600;
}

/* Inputs */
.input-group input {
  width: 100%;
  padding: 12px;
  border: 1px solid #ccc;
  border-radius: 8px;
  transition: border 0.3s;
}

.input-group input:focus {
  border-color: #2575fc;
  outline: none;
}

/* Button styling */
button {
  width: 100%;
  padding: 12px;
  border: none;
  background: #2575fc;
  color: white;
  font-size: 16px;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.3s;
}

button:hover {
  background: #1a5ed1;
}
 

🔍 CSS Explanation

🔹 General Styling

  • *: Resets padding and margin for all elements. box-sizing: border-box ensures paddings are included in width/height.

  • body: Uses flexbox to center the form vertically and horizontally. The background is a beautiful gradient.

🔹 Container

  • login-container: White box with padding, rounded corners, and a drop shadow for a card-like effect.

  • max-width: 400px: Keeps the form compact on large screens.

🔹 Form Elements

  • h2: Centers the form heading.

  • label: Describes the input field.

  • input: Adds padding and a subtle border. On focus, the border color changes for better user interaction.

  • button: A vibrant blue login button with a hover effect.


📱 Step 3: Making It Responsive

This layout is already responsive because we’re using:

  • max-width on the container

  • width: 100% for inputs and buttons

  • flexbox for centering

It works well on both desktop and mobile devices.


✅ Final Output Preview

When you load this form in your browser, you'll see:

  • A centered login card

  • Clean labels and inputs

  • Smooth border and button hover effects

  • A gradient background for a modern touch


📌 Bonus Tips

  • You can add a "Forgot Password?" link below the password field.

  • Use icons next to the inputs for a more stylish look using libraries like Font Awesome.

  • Add media queries if you want to tweak padding/font size for smaller screens.


🎁 Conclusion

You just built a beautiful and modern login form UI using only HTML and CSS! This design is perfect for integrating into any login or authentication page of your website.

With a clean structure and stylish look, your login forms will not only be user-friendly but also visually impressive.


© 2025 Pay18News. All rights reserved.