:user-valid
Widely availableSince 202394% of users
Matches input elements after the user has modified them and they are valid. Provides user-driven validation feedback.
What's modern
From web-features, MDN's browser data and our snippets, checked dailyModernIn every major browser since November 2023. Widely available since May 2026.
The old way and the modern waySee the snippet: Form validation styles without JavaScript →
Old way 11 lines
/* only style after .touched class is added by JS */
input.touched:invalid {
border-color: red;
}
input.touched:valid {
border-color: green;
}
/* JS: add .touched class on blur */
input.addEventListener('blur', () => {
input.classList.add('touched');
});Modern 7 lines
input:user-invalid {
border-color: red;
}
input:user-valid {
border-color: green;
}
/* no JS, no .touched class */See how modern your own CSS is.Check your CSS →
Quick example
input:user-valid { border-color: green; }
input:user-valid::after { content: "✓"; }Examples
Show confirmation after user fills valid input
input:user-valid {
border-color: green;
background-image: url('check.svg');
background-position: right;
}
/* Green check only after user enters valid data */Provide positive feedback when users fill in form fields correctly.
Unlock submit button when form is valid
button[type="submit"]:enabled:user-valid {
opacity: 1;
}
button[type="submit"]:not(:user-valid) {
opacity: 0.5;
}Show visual hint when form is ready to submit (requires JavaScript logic alongside).
Common pitfalls
- :user-valid only for user-touched fieldsA field is :user-valid only if the user has interacted and it's now valid. Pristine, empty fields don't match :user-valid even if they're optional.
- Don't rely on CSS alone for validation:user-valid shows visual feedback but doesn't prevent form submission. Always validate on the backend.
:user-valid browser support
BaselineWidely availableThis feature is well established and works across many devices and browser versions. It has been available across browsers since 2023.Safe to use without fallbacks.
Usage94%of people can use this6% use a browser without it.
Browsers
119+
88+
16.5+
119+Mobile
119+Android
88+Android
16.5+iOS