Languages
[Edit]
EN

CSS - hover child on parent

5 points
Created by:
Violetd
865

In this short article, we would like to show how to set some effect on child on on hover on parent using CSS.

Quick solution:

.parent:hover .child {
    /*
        Put child hover styles here ...
    */
}
Hover effect on child on on hover on parent using CSS.
Hover effect on child on on hover on parent using CSS.

Practical example

// ONLINE-RUNNER:browser;

<!doctype html>
<html>
<head>
  <style>

    .parent {
      	padding: 20px;
      	background: orange;
    }

    .child {
      	padding: 20px;
      	background: gold;
    }

    .parent:hover .child {
      	background: yellow;
    }

  </style>
</head>
<body style="display: flex;">
  <div class="parent">
    Parent!
  	<div class="child">Child!</div>
  </div>
</body>
</html>

 

See also

  1. CSS - How to add style to the parent element when hovering child

Alternative titles

  1. CSS - hover children on parent mouse over
Donate to Dirask
Our content is created by volunteers - like Wikipedia. If you think, the things we do are good, donate us. Thanks!
Join to our subscribers to be up to date with content, news and offers.
Native Advertising
🚀
Get your tech brand or product in front of software developers.
For more information Contact us
Dirask - we help you to
solve coding problems.
Ask question.

❤️💻 🙂

Join