0
I’m trying to make a form template where I think better of the user experience giving visual feedback when the field is filled. Then I came across a "problem" that I can’t explain...
Because in the input
the pseudo class :empty
works, but the :not(:empty)
does not work? Already in the div
both work perfectly.
To illustrate what I speak follow the code. Note that the input
is always red, even if it has content in it. Already in the 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>
In short: I believe the idea of
:empty
for elements. For example, a div<div></div>
is:empty
. In case, input has no closing tag, then it would make no sense to use. If you are trying to check thevalue
, I think the way would be different.– Wallace Maxters
@Wallacemaxters It has no verification or validation, it’s just an UX experiment... the strange thing is that it accepts Empty, but not:Empty... so the input is always Empty because it is void? I got a little carried away with it
– hugocsl
I think it has to do with empty tags, where input is one of them.
– Sam
@sam strongly suspect this...
– hugocsl