:user-valid / :user-invalid
Baseline 2023 (Chrome 119, Safari 16.5, Firefox 88); `:user-invalid` widely available since May 2026.
Chrome 119
Edge 119
Safari 16.5
Firefox 88
Like `:valid`/`:invalid` but only after the user has interacted with the field, so a required field is not red on page load. Gives proper inline validation with zero JS.
CSS
.fx-016 {
font-family: system-ui;
display: grid;
gap: 4px;
max-width: 320px
}
.fx-016 input {
padding: 8px;
border: 1px solid #bbb;
border-radius: 6px
}
.fx-016 input:user-valid {
border-color: #16a34a
}
.fx-016 input:user-invalid {
border-color: #dc2626
}
.fx-016-err {
display: none;
color: #dc2626
}
.fx-016:has(input:user-invalid) .fx-016-err {
display: block
}
.fx-016 :is(a,button,input,select,textarea):focus-visible { outline: 2px solid currentColor; outline-offset: 2px; }
HTML
<form class="fx-016">
<label>Email <input type="email" required placeholder="[email protected]"></label>
<small class="fx-016-err">Enter a valid email address.</small>
</form>Fallback: None needed; if unsupported the field simply is not colored.
Prompt
Style form validation with `:user-invalid` and `:user-valid` rather than `:invalid`, so errors appear only after the user has typed or blurred. Show error text with `.field:has(input:user-invalid) .error { display:block }`. Keep the native `required`, `type` and `pattern` attributes as the validation source instead of JS.