Line Up Form Labels
CSS
Hard
3 views
Problem Description
Create a simple form layout using CSS grid for label and input columns.
Output Format
Print the HTML+CSS code in one block.
Constraints
Use grid-template-columns for label and input.
Official Solution
<!doctype html>
<html lang='en'>
<head>
<meta charset='utf-8'>
<meta name='viewport' content='width=device-width, initial-scale=1'>
<title>meetcode</title>
<style>
form { display: grid; grid-template-columns: 120px 1fr; gap: 10px 12px; max-width: 420px; }
label { align-self: center; }
input { padding: 8px 10px; border: 1px solid #ccc; border-radius: 10px; }
</style>
</head>
<body>
<form action='#'>
<label for='e'>Email</label>
<input id='e' type='email' name='email'>
<label for='p'>Password</label>
<input id='p' type='password' name='password'>
</form>
</body>
</html>
Solutions (0)
No solutions submitted yet. Be the first!
No comments yet. Start the discussion!