Style child element when hover on parent

Rajat Gupta picture Rajat Gupta · Aug 27, 2011 · Viewed 109k times · Source

How to change the style of child element when there is hover on parent element. I would prefer a CSS solution for this if possible. Is there any solution possible through :hover CSS selectors. Actually I need to change color of options bar inside a panel when there is an hover on the panel.

Looking to support all major browsers.

Answer

jtbandes picture jtbandes · Aug 27, 2011

Yes, you can definitely do this. Just use something like

.parent:hover .child {
   /* ... */
}

According to this page it's supported by all major browsers.