I want to change label
color when focusing on .input
<label>This is a label</label>
<input class="input" placeholder="Placeholder"/>
Definetely selecting .input:focus + label
won't work because label
goes first. So, I've tried to do it as label + .input:focus
but I know it doesn't work either.
.search {
padding: 0 5px;
margin: 12px 0;
width: 300px;
height: 25px;
background: white;
border: 1px solid black;
line-height: 25px;
color: gray;
}
/* This is what I want to modify */
.input:focus+label {
color: #f00;
}
.input https://stackoverflow.com/posts/65970655/edit#{
padding: 0 5px;
margin: 7.5px 0;
border: 2px solid black;
z-index: 2;
width: 300px;
height: 25px;
background: transparent;
}
.input:focus {
outline: red;
border: 2px solid red;
}
<h2> This what I want to modify</h2>
<label>This is a label</label>
<input class="input" placeholder="Placeholder" />
<br>
<h2>Changing the order does work </h2>
<input class="input" placeholder="Placeholder" />
<label>This is a label</label>