Can I use CSS :hover to effect another elements properties?

css, css-selectors

Solution

You can use `:hover` anywhere in a compound selector, so if you can select the elements you want to change while including `:hover`, then yes.

In this case, you can't really do it with `itemImage` because it involves backtracking up the DOM, but you can do it with `itemImageLink`, for instance:

.itemImageLink:hover ~ .itemTitle {
    ...
}

Problem

I am attempting to change a text links properties (different colour and text-decoration:underline;) when hovering over its corresponding image. This is the html: ``` <!-- Wraps image, title, category --> <div class="itemWrap"> <!-- Item Image --> <a href="#" class="itemImageLink"><img class="itemImage" src="img/thumb.png" alt="thumb"></a> <!-- Item Title --> <div class="itemTitle"> <a href="#">The original soul of Michael Jackson</a> </div> <!-- Item Category --> <div class="itemCat"> <a href="#">12" Picture Disc</a> </div> </div><!-- close itemWrap --> ``` Is it possible that when hovering over the itemImage (which is encased in an anchor) that the properties of a link within .itemTitle can be changed? It might be worth noting that the itemWrap is used multiple times on the webpage. Thanks

Original source