:user-invalid (:-moz-ui-invalid)
Quick Summary for :user-invalid
The
:user-invalid
CSS pseudo-class represents any validated form element whose value isn't valid based on their validation constraints, after the user has interacted with it.
Code Usage for :user-invalid
<form> <label for="email">Email *: </label> <input id="email" name="email" type="email" required> <span></span> </form>
More Details for :user-invalid
:user-invalid (:-moz-ui-invalid)
The :user-invalid
CSS pseudo-class represents any validated form element whose value isn't valid based on their validation constraints, after the user has interacted with it.
The :user-invalid
pseudo-class must match an :invalid
, :out-of-range
, or blank-but :required
element between the time the user has attempted to submit the form and before the user has interacted again with the form element.
Note: The pseudo-class behaves in the same way as the non-standard :-moz-ui-invalid
pseudo-class.
Syntax
:user-invalid
Examples
Setting a color and symbol on :user-invalid
In the following example, the red border and ❌ only display once the user has interacted with the field. Try typing something other than an email address to see it in action.
<form> <label for="email">Email *: </label> <input id="email" name="email" type="email" required> <span></span> </form>
input:user-invalid { border: 2px solid red; } input:user-invalid + span::before { content: '✖'; color: red; }
Specifications
Specification |
---|
Selectors Level 4 # user-invalid-pseudo |
See also
:valid
:invalid
:required
:optional
:user-valid
Last modified: Aug 12, 2021, by MDN contributors
Select your preferred language English (US)DeutschEspañolFrançais日本語 Change language Posted in
12:22 am, February 22, 2022
Add Comment
Other Items in CSS
rgb()
rgba()
:right
right
@right-bottom
:root
rotate
rotate()
rotate3d()
rotateX()
rotateY()
rotateZ()
row-gap
ruby-align
ruby-position
saturate()
scale
scale()
scale3d()
scaleX()
scaleY()
scaleZ()
:scope
scroll-behavior
scroll-margin
scroll-margin-block
scroll-margin-block-end
scroll-margin-block-start
scroll-margin-bottom
scroll-margin-inline
scroll-margin-inline-end
scroll-margin-inline-start
scroll-margin-left
scroll-margin-right
scroll-margin-top
scroll-padding
scroll-padding-block
scroll-padding-block-end
scroll-padding-block-start
scroll-padding-bottom
scroll-padding-inline
scroll-padding-inline-end
scroll-padding-inline-start
scroll-padding-left
scroll-padding-right
scroll-padding-top
scroll-snap-align
scroll-snap-stop
scroll-snap-type
@scroll-timeline