How can I style a label element that precedes an input when I focus on the input element?
Take the following code:
label {
background: red;
}
input[type="text"]:focus ~ label {
background: blue;
}
<div>
<label>Hello World</label>
<input type="text">
</div>
On focus of the input I want to change the style of the preceding label element using the general sibling selector ('~'). What am I doing wrong?