Checking if an input is empty with CSS
Is it possible to know if an input is empty with only CSS?
I had that question when I tried to make an autocomplete component for Learn JavaScript. Basically, I wanted to:
- Hide a dropdown if the input is empty
- Show the dropdown if the input is filled

(Pardon the messed-up gif.. but you get the idea!)
I found a way to do it. It’s not perfect. There are a few nuances involved, but I want to share it with you.
https://zellwk.com/blog/check-empty-input-css
Enjoy!
Stay awesome,
Zell