I'm creating a form using only html and css. I want each question on the form to have a visual aid by giving it's containing div a red border-left color that changes to green if the input field is filled in.
This is my html:
<div class="form-unit">
<label for="name" id="name-label"><b>Name</b></label>
<input type="text" id="name" placeholder="Please enter your full name" required>
</div>
And this is the relevant css:
.form-unit {
margin: 40px 0;
padding-left: 15px;
border-left: 3px solid rgb(200, 80, 100);
}
I want to change the color of the div's border like so:
.form-unit:??? {
border-left: 3px solid rgb(160, 200, 80);
}
What is the syntax to target the div when the input[type="text"]
is not empty? Is it at all possible with just html and css?