How do I apply a style to an empty input box? If the user types something in the input field, the style should no longer be applied. Is this possible in CSS? I tried this:
input[value=""]
If only the field is required
you could go with input:valid
#foo-thing:valid + .msg { visibility: visible!important; }
<input type="text" id="foo-thing" required="required">
<span class="msg" style="visibility: hidden;">Yay not empty</span>
See live on jsFiddle
OR negate using #foo-thing:invalid
(credit to @SamGoody)