Categories
CSS

How to affect other elements when one element is hovered with CSS?

Spread the love

To affect other elements when one element is hovered with CSS, we use the :hover pseudoclass.

For instancne, we write

#container:hover #cube {
  background-color: yellow;
}

to select the element with ID container when we hover over it with #container:hover.

And we select the element with ID cube inside and set its background color to yellow.

By John Au-Yeung

Web developer specializing in React, Vue, and front end development.

Leave a Reply

Your email address will not be published. Required fields are marked *