on hover change style of another element code example

Example 1: css hover change another element

#a:hover ~ #b {
    background: #ccc
}

<div id="a">Div A</div>
<div>random other elements</div>
<div>random other elements</div>
<div>random other elements</div>
<div id="b">Div B</div>

Example 2: css hover change other element

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

Example 3: css hover change another element

#a:hover + #b {
    background: #ccc
}

<div id="a">Div A</div>
<div id="b">Div B</div>

Tags:

Css Example