I\'m building a form and I want to use the :invalid selector to give the \"required\" input fields a red border if the user presses submit without filling them, but
:invalid
Another way is to add a hide-hints class to the inputs with JavaScript on load. When a user modifies a field you remove the class.
hide-hints
In your CSS you then apply styling to input:not(.hide-hints):invalid. This means the error styling will be shown for users without JavaScript as well.
input:not(.hide-hints):invalid