CSS3 :optional Selector
Example
Select and style only if the <input> element does not have a "required" attribute:
input:optional
{
background-color: yellow;
}
Try it Yourself »
Definition and Usage
The :optional selector selects form elements which are optional.
Form elements with no required attribute are defined as optional.
Note: The :optional selector only applies to the form elements: input, select and textarea.
Tip: Use the :required selector to select form elements which are required.
Version: | CSS3 |
---|
Browser Support
The numbers in the table specifies the first browser version that fully supports the selector.
Selector | |||||
---|---|---|---|---|---|
:optional | 10.0 | 10.0 | 4.0 | 5.0 | 10.0 |
CSS Syntax
:optional {
css declarations;
}
Related Pages
CSS Selector :required