Lesson 5 of 10
Modern Login Form
Login forms are a core UI pattern. Build a professional login form with floating labels, validation states, social login buttons, password visibility toggle styling, and a glassmorphism card - all with modern CSS.
Login Form Elements
- Card container - Centered glassmorphism or white card with shadow on a gradient background
- Floating labels - Labels that shrink and move up when input is focused or has value
- Input styling - Large inputs with border transitions on focus, icon prefixes
- Validation - Green/red borders with checkmark/x icons using :valid/:invalid pseudo-classes
- Social buttons - 'Sign in with Google/GitHub' styled as outlined buttons with icons
- Forgotten password link - Subtle text link below the password field
- Responsive - Form fills 90% width on mobile, max-width: 420px on desktop
Mini-Build: Login Form
Tip
The glassmorphism login card uses backdrop-filter: blur(10px) + semi-transparent background (rgba(255,255,255,0.95)). This creates a frosted-glass effect that looks premium. It works over any background - gradient, image, or video.
Design accessible, modern authentication cards with focus rings and smooth interactive states
Common Mistake
Using font-size smaller than 16px on form inputs. iOS Safari auto-zooms into inputs with font-size below 16px, breaking the user's viewport. Always set font-size: 1rem (16px) or larger on all form inputs.
Practice Task
Enhance the login form: (1) Add input:focus border-color transition + box-shadow glow, (2) Add input:valid green border with a checkmark, (3) Make the submit button :active { transform: scale(0.95) }, (4) Test at 375px mobile width.
Quick Quiz
Key Takeaways
- Login forms are a core UI pattern.
- Card container - Centered glassmorphism or white card with shadow on a gradient background
- Floating labels - Labels that shrink and move up when input is focused or has value
- Input styling - Large inputs with border transitions on focus, icon prefixes
Finished this lesson?