Css has specified two pseudo-classes that should select an element when it has no contents, :empty
and :blank
, but both of these enjoy different browser support and aren't always right for the situation where you want to apply styles. Especially when the situation is styling <input>
tags, being able to detect when the tag is completely empty can be very useful.
Value is undefined
:
!element.value
@element select {
eval('!value && "$this"') {
border: 5px solid lime;
}
}
select[test='!this.value'] {
border: 5px solid lime;
}