Create a simple login form
- User
Create a simple login form
Assistant
Here's a simple, responsive login form with clean styling and accessible markup:
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Login Form</title> <style> /* Reset some default styles */ * { margin: 0; padding: 0; box-sizing: border-box; } body { font-family: Arial, sans-serif; background-color: #f4f4f4; display: flex; justify-content: center; align-items: center; height: 100vh; } .login-container { background-color: #fff; padding: 2rem; border-radius: 8px; box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1); width: 100%; max-width: 400px; } .login-container h2 { text-align: center; margin-bottom: 1.5rem; color: #333; } .form-group { margin-bottom: 1rem; } label { display: block; margin-bottom: 0.5rem; color: #555; } input[type="text"], input[type="password"] { width: 100%; padding: 0.75rem; border: 1px solid #ddd; border-radius: 4px; transition: border-color 0.3s ease; } input:focus { border-color: #007bff; outline: none; } button { width: 100%; padding: 0.75rem; background-color: #007bff; border: none; border-radius: 4px; color: white; font-size: 1rem; cursor: pointer; transition: background-color 0.3s ease; } button:hover { background-color: #0056b3; } .bottom-text { margin-top: 1rem; font-size: 0.9rem; text-align: center; } .bottom-text a { color: #007bff; text-decoration: none; } .bottom-text a:hover { text-decoration: underline; } </style> </head> <body> <div class="login-container"> <h2>Login</h2> <form action="#" method="POST"> <div class="form-group"> <label for="username">Username or Email</label> <input type="text" id="username" name="username" placeholder="Enter your username or email" required> </div> <div class="form-group"> <label for="password">Password</label> <input type="password" id="password" name="password" placeholder="Enter your password" required> </div> <button type="submit">Login</button> <div class="bottom-text"> Don't have an account? <a href="#">Register here</a> </div> </form> </div> </body> </html>Key Features:
- Responsive Design: Works well on different screen sizes
- Accessible Markup: Proper labels and focus states
- Modern Styling: Subtle shadows, rounded corners, hover effects
- User Guidance: Placeholder text in inputs
- Visual Hierarchy: Clear spacing and typography
- Interactive Elements: Focus and hover states for better UX
This form is fully functional as a front-end component and can be integrated with backend systems by modifying the
actionattribute of the form tag.