I would like to make all labels
have color: red;
if their sibling
input
has no value
.
I try to select first the inputs
without a value
like this:
.state-input--red > .input__wrapper > .input__input:not([value])
And after that I'm trying to select his sibling
label
adding this part:
~ .input__label
So I got this selection and setting color
to red
, but it doesn't work:
.state-input--red > .input__wrapper > .input__input:not([value]) ~ .input__label {
color: red;
}
I also tried to specify the sibling
selection by adding also the .input__wrapper >
before the label
, but it doesn't work. Here is my snippet:
.state-input--red > .input__wrapper > .input__input:not([value]) ~ .input__label {
color: red;
}
<div class="input state-input--red">
<div class="input__wrapper">
<label class="input__label" for="input00">I should be black, because my siblin input has a value</label>
<input id="input00" type="text" value="Hello World">
</div>
</div>
<hr>
<div class="input state-input--red">
<div class="input__wrapper">
<label class="input__label" for="input01">I should be red, because my sibling input has no value</label>
<input id="input01" class="input__input" type="text">
</div>
</div>