2
I have the following HTML structure:
<form action="" id="form-contato">
<label for="nome">Nome</label>
<input type="text" name="nome" id="nome" placeholder="Nome"/>
<label for="email">E-mail</label>
<input type="email" name="email" id="email" placeholder="[email protected]">
<label for="assunto">Assunto</label>
<input type="text" name="assunto" id="assunto" placeholder="Assunto">
<label for="mensagem">Mensagem</label>
<textarea name="mensagem" id="mensagem" placeholder="Escreva aqui sua mensagem"></textarea>
<button class="bt">Enviar</button>
</form>
I would like to select the last label corresponding to the input that received focus to stylize it and emphasize which field is focused.
For example, when focusing on input with id="name" I would like to select the label with attribute for="name".
I tried to finish the dial ~, but this would only work if the label came after input, which would make HTML semantic.
Thanks in advance! (y)
you want to do this using only css? or involving JS as well? Because if it is only css you need to change your html structure
– celsomtrindade
Initially I would like to do only with CSS, but I realized that is not possible, so I ended up applying a solution with Javascript.
– Cleiton Pereira
Possible is, only it would change its HTML structure
– celsomtrindade