Lesson 8 of 9
Building Real-World Forms
Now that you know all the individual form elements, it's time to build complete, real-world forms. This topic walks through common form patterns used in production websites: login forms, registration forms, contact forms, search bars, and multi-step forms. Each pattern demonstrates best practices for structure, validation, accessibility, and user experience.
Common Form Patterns
- Login form - email + password + 'Remember me' checkbox + 'Forgot password' link. Use autocomplete='current-password' for returning users.
- Registration form - name + email + password + confirm password + terms checkbox. Use autocomplete='new-password' to trigger browser's password generator.
- Contact form - name + email + subject (select dropdown) + message (textarea) + submit. Include honeypot field for basic spam prevention.
- Search form - search input + submit button. Wrap in <form role='search'> for accessibility. Use type='search' for clear button on mobile.
- Newsletter signup - inline email input + submit button. Single row layout. Use minimal fields to maximize conversions.
- Multi-step form - One fieldset per step, show/hide with CSS/JS. Add a progress indicator (<progress> or step numbers).
- Checkout form - Shipping address + payment details + order summary. Use fieldset for each section. Include autocomplete values for all fields.
Login Form Example
Login Form Example
<!DOCTYPE html>
<html>
<head>
<style>
.form-card { max-width:400px; margin:40px auto; padding:32px; background:white; border-radius:16px; box-shadow:0 4px 24px rgba(0,0,0,0.1); font-family:Arial,sans-serif; }
.form-card h2 { text-align:center; color:#333; margin-bottom:24px; }
label { display:block; margin:12px 0 4px; font-weight:600; color:#555; }
input[type="email"], input[type="password"] { width:100%; padding:12px; border:1px solid #ddd; border-radius:8px; font-size:15px; box-sizing:border-box; }
input:focus { outline:none; border-color:#229c6b; box-shadow:0 0 0 3px rgba(4,170,109,0.2); }
.btn { width:100%; padding:14px; margin-top:20px; background:#229c6b; color:white; border:none; border-radius:8px; font-size:16px; font-weight:bold; cursor:pointer; }
.btn:hover { background:#039960; }
.extras { display:flex; justify-content:space-between; align-items:center; margin-top:12px; font-size:14px; }
.extras a { color:#229c6b; text-decoration:none; }
</style>
</head>
<body style="background:#f5f5f5">
<div class="form-card">
<h2>🔐 Log In</h2>
<form action="/login" method="POST">
<label for="email">Email</label>
<input type="email" id="email" name="email" required autocomplete="email" placeholder="you@example.com">
<label for="pwd">Password</label>
<input type="password" id="pwd" name="password" required minlength="8" autocomplete="current-password" placeholder="Min 8 characters">
<div class="extras">
<label style="margin:0;font-weight:normal"><input type="checkbox" name="remember"> Remember me</label>
<a href="/forgot-password">Forgot password?</a>
</div>
<button type="submit" class="btn">Log In</button>
</form>
</div>
</body>
</html>Diagram
Loading diagram…
Organize large multi-step forms into logical semantic sections
Key Takeaways
- Now that you know all the individual form elements, it's time to build complete, real-world forms.
- Login form - email + password + 'Remember me' checkbox + 'Forgot password' link. Use autocomplete='current-password' for returning users.
- Registration form - name + email + password + confirm password + terms checkbox. Use autocomplete='new-password' to trigger browser's password generator.
- Contact form - name + email + subject (select dropdown) + message (textarea) + submit. Include honeypot field for basic spam prevention.
Finished this lesson?
0 of 9 in Module 6