diff --git a/snippets/focus-within.md b/snippets/focus-within.md new file mode 100644 index 000000000..811b4b2f3 --- /dev/null +++ b/snippets/focus-within.md @@ -0,0 +1,51 @@ +### Focus Within + +Changes the appearance of a form if any of its children are focused. + +#### HTML + +```html +
+
+ + +
+ + +
+
+``` + +#### CSS + +```css +form { + border: 3px solid #2d98da; + color: #000000; + padding: 4px; +} + +form:focus-within { + background: #f7b731; + color: #000000; +} +``` + +#### Demo + + + +#### Explanation + +The psuedo class `:focus-within` applies styles to a parent element if any child element gets focused. For example, an `input` element inside a `form` element. + +#### Browser support + +⚠️ Not supported in IE11 or the current version of Edge. + + + +- https://caniuse.com/#feat=css-focus-within + +