Is there a way to select the input of a file that is empty?
No.
You will need JavaScript. Here you can find some answers on SO and in other places. The main idea is to observe the change event element, add a class, such as non-empty , indicating that there are files, and then the input[type="file"].non-empty + label style input[type="file"].non-empty + label , provided that you use the technique of using label as the file to replace the enter button. You will need a special case of form.reset() , which entangles input files in the form, but does not raise a change event in the input. Here is a sample code (without the form.reset part):
input[type="file"] { width: 0.1px; height: 0.1px; } input[type="file"].non-empty + label { color: green; } input[type="file"].non-empty + label::after { content: ' (specified)'; }
<input type="file" id="input"> <label for="input">Specify file</label>
user663031
source share