I'm trying to make a form template where I think of the user experience better by giving visual feedback when the field is filled out. There I came across a "problem" that I can not explain ...
Because no input
pseudo class :empty
works, but :not(:empty)
does not work? In div
both work perfectly.
To illustrate what I say follows the code. Notice that the input
is always red, even with content inside. While div
works perfectly.
input:empty {
border: 2px solid red;
}
input:not(:empty) {
border: 2px solid green;
}
div:empty {
border: 2px solid red;
}
div:not(:empty) {
border: 2px solid green;
}
div {
width: 100px;
height: 30px;
}
<input type="text">
<input type="text" value="content">
<div></div>
<div>content</div>