From d97f0a56a6f8856f283a7c65014820bab278c728 Mon Sep 17 00:00:00 2001 From: githrdw Date: Tue, 5 Mar 2019 23:40:19 +0100 Subject: [PATCH] Added optional selector (#28540) * Added optional selector Added optional selector * Update index.md --- .../css/selectors/pseudo/optional/index.md | 23 +++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 guide/english/css/selectors/pseudo/optional/index.md diff --git a/guide/english/css/selectors/pseudo/optional/index.md b/guide/english/css/selectors/pseudo/optional/index.md new file mode 100644 index 0000000000..fb509bd458 --- /dev/null +++ b/guide/english/css/selectors/pseudo/optional/index.md @@ -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)