Html – CSS Hover over something and have a completely different div change its attribute

csshtml

im trying to write a code where you hover over a div and have a completely different div change its effect

heres my code

html

    <div class="a">LOREM IPSUM</div>
    <div class="boxhighlight"></div>

css

    .a:hover, .boxhighlight
    {
        background-color:black;
    }

what i want to happen is that when the user hovers over the word lorem ipsum, the div boxhighlight will change its background color

is there a way to do this?

thanks

Best Answer

Use like this

<div class="a">LOREM IPSUM</div>
<div class="boxhighlight" >asdf</div>

Your css

.a:hover ~ .boxhighlight  {
background-color:black;
color: white;
}

See this for your Reference

See example in this Fiddle

Related Topic