CSS :optional Selector

The :optional pseudo class targets inputs (including <select>s) that are not specifically set as required (do not have the required attribute).This can be useful when you want to give optional fields a specific look, maybe slightly less visible than required ones.

The :optional CSS pseudo-class represents any <input>, <select>, or <textarea> element that does not have the required attribute set on it.

The :optional selector selects form elements which are optional.Form elements with no required attribute are defined as optional.

:optional {css declarations;}

Example -