I have a form where I placed my labels before inputs like this:
<label for="email">Confirm Email</label>
<input type="text" id="email" />
<label for="firstname">First Name</label>
<input type="text" id="firstname" />
<label for="lastname">Last Name</label>
<input type="text" id="lastname" />
<label for="company">Company</label>
<input type="text" id="company" />
When I try to use the CSS to style the label, when I hover the inputs like this (input:hover + label
), the CSS applies on the next label instead on the one that has the for=
property. For example, if I try to hover the email input, it will apply the input:hover+label
effect on the 2nd label with for="firstname"
.
My design structure has labels on top and inputs under them, so I can't switch their position.
Is there any solution to this?