Build a Job Application Form - Build a Job Application Form

Tell us what’s happening:

Step 15 asks that you change the label associated with the input by using the :checked pseudo-class. In the HTML section of the curriculum, when learning about labels, in the example the label is placed before the input. So my question is, how do I properly reference the label from the input without having to rearrange the label to come after the input.

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">
            
            <label for="email">Email</label>
            <input type="email" id="email">

            <label for="position">Position</label>
            <select id="position">
                <option>Manager</option>
                <option>Team Member</option>
                <option>HR</option>
            </select>

            <fieldset class="radio-group">
                <legend>Availability</legend>

                <label for="full-time">Full Time</label>
                <input type="radio" id="full-time" name="availability">

                <label for="part-time">Part Time</label>
                <input id="part-time" type="radio" name="availability">

                
            </fieldset>

            <label for="message">Any Additional Information?
            <textarea id="message"></textarea>

            <button type="submit">Submit</button>
        </form>
    </div>
</body>
</html>
/* file: styles.css */
input:focus, textarea:focus {
  border: 2px solid blue;
}

input:invalid, select:invalid, textarea:invalid {
  border: 2px solid red;
}

input:valid, select:valid, textarea:valid {
  border: 2px solid green;
}

button:hover {
  background-color: green;
}

.radio-group input[type="radio"]:checked {
  border: 2px solid green;
  background-color: green;
  box-shadow: 2px 2px 2px;
}

input:first-of-type {
  background-color: gray;
  border-radius: 3px;
}

input[type="radio"]:checked + label {
  color: green;
}

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/136.0.0.0 Safari/537.36 Edg/136.0.0.0

Challenge Information:

Build a Job Application Form - Build a Job Application Form

I don’t see why you want the label to be before the input? I don’t see that in the instructions for this project or the sample.

the label can go before, after or around the input, those are all correct

1 Like

If I put the label before the input, how do I reference the label when the input is checked? I completed the lab by rearranging the labels, so now I’m just asking out of curiosity, because I do genuinely believe that there has to be a way to use CSS to reference a label that comes before an input by using input:checked.

This is probably what you want then

The next-sibling combinator can be included within the :has() functional selector to select the previous sibling.