CSS: .container {
position: relative;
padding-top: 25px;
}
#def + label {
position: absolute;
left: 4px;
transition: top 0.2s ease-in-out, color 0.2s ease-in-out;
top: 25px;
}
#def:not(:focus):valid + label {
color: gray;
}
#def:focus + label, #def:not(:valid) + label {
color: black;
top: 0px;
}