:optional Back
:optional
is a CSS pseudo-class selector used to select form elements that are optional.- More specifically, it is used to select form elements that are not required; that is, form elements that do not have the required attribute set.
- The form elements than can be selected using
:optional
are<input>
s,<select>
s, and<textarea>
s without a required attribute.
Case: learning :optional
See the Pen LGadwJ by aleen42 (@aleen42) on CodePen.
Note
- If you want to select form elements that are required, you can use the
:required
pseudo-class selector.