Is it possible to style another element on :focus of a specific element?
Something like:
input:focus #header {
display: none;
}
I tried doing that but it didn't work.
You will begin by using the type selector to select HTML elements to style. Then, you will combine selectors to identify and apply styles more precisely. Lastly, you will group several selectors to apply the same styles to different elements.
As per the spec: The :focus pseudo-class applies while an element has the focus (accepts keyboard events or other forms of text input). The <div> does not accept input, so it cannot have :focus . Furthermore, CSS does not allow you to set styles on an element based on targeting its descendants.
Elements of the following type are focusable if they are not disabled: input , select , textarea , button , and object . Anchors are focusable if they have an href or tabindex attribute. area elements are focusable if they are inside a named map, have an href attribute, and there is a visible image using the map.
Yes,it is possible if element is a sibling
or a child
to the :focus
element. If it is not your case (affect whatever you want) than you should use javascript.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With