Question: Create a student registration form using HTML which has the following
controls and make an interactive content presentation using CSS.:
1. Text Box
II. Dropdown box
III. Option/radio buttons
IV. Check boxes V. Reset and Submit button
Ans. HTML (Student Registration Form)
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Student Registration Form</title>
<link rel="stylesheet" href="styles.css">
</head>
<body>
<div class="form-container">
<h2>Student Registration Form</h2>
<form action="#" method="POST">
<!-- Text Box for Name -->
<label for="name">Full Name:</label>
<input type="text" id="name" name="name" required placeholder="Enter your
full name">
<!-- Dropdown box for Gender -->
<label for="gender">Gender:</label>
<select id="gender" name="gender">
<option value="male">Male</option>
<option value="female">Female</option>
<option value="other">Other</option>
</select>
<!-- Radio buttons for Course -->
<label for="course">Select Course:</label>
<div class="radio-group">
<input type="radio" id="course1" name="course" value="Computer Science">
<label for="course1">Computer Science</label>
<input type="radio" id="course2" name="course" value="Mathematics">
<label for="course2">Mathematics</label>
<input type="radio" id="course3" name="course" value="Engineering">
<label for="course3">Engineering</label>
</div>
<!-- Checkboxes for Subjects -->
<label>Subjects:</label>
<div class="checkbox-group">
<input type="checkbox" id="subject1" name="subject" value="Physics">
<label for="subject1">Physics</label>
<input type="checkbox" id="subject2" name="subject" value="Chemistry">
<label for="subject2">Chemistry</label>
<input type="checkbox" id="subject3" name="subject" value="Biology">
<label for="subject3">Biology</label>
</div>
<!-- Submit and Reset Buttons -->
<div class="button-group">
<button type="submit" class="submit-btn">Submit</button>
<button type="reset" class="reset-btn">Reset</button>
</div>
</form>
</div>
</body>
</html>
CSS (styles.css)
/* Basic styling for the form */
body {
font-family: Arial, sans-serif;
background-color: #f4f4f4;
display: flex;
justify-content: center;
align-items: center;
height: 100vh;
margin: 0;
}
.form-container {
background-color: #fff;
padding: 20px;
border-radius: 10px;
box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
width: 400px;
}
h2 {
text-align: center;
color: #333;
}
label {
display: block;
margin-bottom: 8px;
font-weight: bold;
color: #555;
}
input[type="text"],
select {
width: 100%;
padding: 8px;
margin-bottom: 16px;
border: 1px solid #ccc;
border-radius: 5px;
}
input[type="radio"],
input[type="checkbox"] {
margin-right: 10px;
}
.radio-group,
.checkbox-group {
display: flex;
flex-direction: column;
margin-bottom: 16px;
}
.button-group {
display: flex;
justify-content: space-between;
}
button {
padding: 10px 20px;
border: none;
border-radius: 5px;
cursor: pointer;
font-size: 16px;
}
.submit-btn {
background-color: #4CAF50;
color: white;
}
.reset-btn {
background-color: #f44336;
color: white;
}
button:hover {
opacity: 0.8;
}
/* Styling for form controls on focus */
input:focus, select:focus {
border-color: #4CAF50;
outline: none;
}
input[type="radio"]:checked + label,
input[type="checkbox"]:checked + label {
color: #4CAF50;
}