JSFiddle - React, Tailwind, and code Playground
HTML
<label id="label1">label без for <input id="inp" type="text"></label>
<br>
<br>
<br>
<label id="label2" for="inp">other label</label>
CSS
.outline_red {
outline: dashed 2px red;
}
.outline_blue {
outline: dashed 2px blue;
}
.border_green {
border: solid 2px green;
}
JavaScript
label1.onmouseover = function() {
this.control.classList.toggle('outline_red');
}
label2.onmouseover = function() {
this.control.classList.toggle('border_green');
}
inp.onmouseover = function() {
this.labels.forEach(label => label.classList.toggle('outline_blue'));
}