Tell us what’s happening:
- You should use the :checked pseudo-class on radio buttons to change the text color of the associated label when the option is selected. i have been building job application and have encountered the error, have tried all possibilities but the error still persists
Your code so far
<!-- file: index.html -->
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Job Application Form</title>
<link rel="stylesheet" href="styles.css">
</head>
<body>
<div class="container">
<form>
<label for="name">Full Name</label>
<input type="text" id="name" name="name" placeholder="Enter your full name" required>
<label for="email">Email Address</label>
<input type="email" id="email" name="email" placeholder="Enter your email" required>
<label for="position">Position Applied For</label>
<select id="position" name="position" required>
<option value="">-- Select a position --</option>
<option value="developer">Software Developer</option>
<option value="designer">UI/UX Designer</option>
<option value="manager">Project Manager</option>
</select>
<fieldset class="radio-group">
<legend>Availability</legend>
<input type="radio" id="full-time" name="availability" value="full-time" checked>
<label for="full-time">Full-Time</label>
<input type="radio" id="part-time" name="availability" value="part-time">
<label for="part-time">Part-Time</label>
</fieldset>
<label for="message">Cover Letter</label>
<textarea id="message" name="message" rows="5" placeholder="Write a short message..." required></textarea>
<button type="submit">Submit Application</button>
</form>
</div>
</body>
</html>
/* file: styles.css */
.radio-group {
margin: 10px 0;
}
input,
select,
textarea {
padding: 10px;
margin: 5px 0;
display: block;
width: 200px;
border: 1px solid #ccc;
box-sizing: border-box;
}
input:first-of-type {
background-color: #eef5ff;
}
input:focus,
textarea:focus {
border-color: blue;
outline: none;
}
input:invalid,
select:invalid,
textarea:invalid {
border-color: red;
}
input:valid,
select:valid,
textarea:valid {
border-color: green;
}
/* Hide radio buttons */
.radio-group input[type="radio"] {
position: absolute;
opacity: 0;
}
/* Radio labels */
.radio-group label {
display: inline-block;
padding: 10px 15px;
border: 1px solid #ccc;
background-color: #f8f9fa;
cursor: pointer;
margin-right: 5px;
color: black;
}
/* ✅ TEST 15 — border color using :checked */
.radio-group:has(input[type="radio"]:checked) {
border-color: blue;
background-color: #e9ecef;
}
/* ✅ TEST 16 — background color using :checked */
.radio-group input[type="radio"]:checked {
background-color: #e9ecef;
border-color: purple;
box-shadow: 0 0 5px rgba(0, 0, 0, 0.3);
}
/* ✅ TEST 17 — box shadow using :checked */
.radio-group input[type="radio"]:checked {
box-shadow: 0 0 5px rgba(0, 0, 0, 0.3);
}
.radio-group label {
display: inline-block;
padding: 10px 15px;
border: 1px solid #ccc;
background-color: #f8f9fa;
cursor: pointer;
margin-right: 5px;
margin-top: 0;
color: black; /* Default text color */
transition: all 0.2s ease;
}
.radio-group input[type="radio"]:checked + label {
color: green ; /* Specifically changes text color */
background-color: #e9ecef; /* Provides visual feedback */
border-color: blue;
box-shadow: 0 0 5px rgba(0, 0, 0, 0.3);
}
/* Button base style */
button {
padding: 10px 15px;
background-color: #007bff;
color: white;
border: none;
cursor: pointer;
}
/* Button hover */
button:hover {
background-color: #0056b3;
}
label {
cursor: pointer;
color: #333; /* Default color */
transition: color 0.2s;
margin-right: 15px;
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/144.0.0.0 Safari/537.36
Challenge Information:
Build a Job Application Form - Build a Job Application Form