Added optional selector (#28540)

* Added optional selector

Added optional selector

* Update index.md
This commit is contained in:
githrdw
2019-03-05 23:40:19 +01:00
committed by Randell Dawson
parent 286ef61b1a
commit d97f0a56a6

View File

@ -0,0 +1,23 @@
---
title: Optional
---
## Optional
The CSS :optional selector changes the style of an input element if the `required` tag is not used.
The :optional selector can be used on the input, select and textarea element
In the example below, the required field will be blue and the optional field red
```css
input {
background-color: blue;
}
input:optional {
background-color: red;
}
```
#### More Information:
* [MDN Web Docs](https://developer.mozilla.org/en-US/docs/Web/CSS/:optional)
* [W3 Schools](https://www.w3schools.com/cssref/sel_optional.asp)