Added optional selector (#28540)
* Added optional selector Added optional selector * Update index.md
This commit is contained in:
23
guide/english/css/selectors/pseudo/optional/index.md
Normal file
23
guide/english/css/selectors/pseudo/optional/index.md
Normal 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)
|
Reference in New Issue
Block a user