Login Form In HTML and CSS

Let's create a simple and responsive Login Form in HTML and CSS.

Watch on YouTube

HTML

                    
content_copy copy
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Log In</title> <link rel="stylesheet" href="/style.css"> </head> <body> <div class="container"> <h1>Log In</h1> <form action=""> <input type="text" placeholder="User Name" class="user-name"> <input type="password" placeholder="Password" class="password"> <a href="#" class="forgot-pass">Forgot password</a> <button>Log In</button> <p class="signup-call"> Not a Member? <a href="#">SignUp</a> </p> </form> </div> </body> </html>

CSS

                    
content_copy copy
*{ margin: 0; padding: 0; box-sizing: border-box; } body{ height: 100vh; background-image: url("/assets/bg.jpg"); background-size: cover; background-repeat: none; background-position: center; display: flex; align-items: center; justify-content: center; } .container{ width: 30rem; height: 30rem; backdrop-filter: brightness(0.9); border: 1px solid white; border-radius: 0.5rem; display: flex; align-items: center; flex-direction: column; gap: 3rem; justify-content: center; } h1{ font-size: 2.5rem; color: cyan; } form{ height: 17rem; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2rem; } input, button{ height: 2.5rem; width: 18rem; color: black; font-size: 1rem; border: none; border-radius: 2rem; outline: none; padding-left: 1rem; } input::placeholder{ color: darkgray; } button{ font-size: 1.3rem; background-color: cyan; } button:hover{ background-color: white; } a{ color: white; text-decoration: none; } .forgot-pass, .signup-call{ color: white; font-size: 1.2rem; } .forgot-pass{ align-self: flex-end; margin-top: -1.5rem; } a:hover{ color: cyan; } @media (max-width: 576px) { html{ font-size: 15px; } } @media (min-width: 576px) { html{ font-size: 16px; } } @media (min-width: 992px) { html{ font-size: 18px; } }