Easy Tutorial
❮ Pr Gen Content Pr Border Right Color ❯

CSS :optional Selector

Complete CSS Selector Reference

Example

Set the input element to yellow if it does not have the "required" attribute:


Definition and Usage

The :optional selector styles form elements that are optional.

Form elements are considered optional if they do not have the required attribute explicitly set.

Note: The :optional selector only applies to form elements: input, select, and textarea.


Browser Support

The numbers in the table specify the first browser version that fully supports the attribute.

Selector
:optional 10.0 10.0 4.0 5.0 10.0

CSS Syntax


Related Pages

CSS Selector :required


Complete CSS Selector Reference

❮ Pr Gen Content Pr Border Right Color ❯