Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

CSS

Is there a way to change the color of an svg and a a link simultaneously when hovering?

Hello,

I am trying to change the color (using CSS) of my inline svg and span at the same time when I hover my mouse over either one. I can get it to work when I hover over the svg but not when I hover over the span. Any help would be greatly appreciated.

<li>

         <!------- Navigation Heart -------->

          <a href="#"> <svg version="1.1" id="nav-icon" class="heart" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
 viewBox="0 0 28 24" style="enable-background:new 0 0 28 24;" xml:space="preserve">

<style type="text/css"> .st0{fill:#39ADD1;} </style> <path class="st0" d="M28,7.1C28,4.2,25.5,0,20.7,0C15.8,0,14,6.6,14,6.6S12.2,0,7.3,0C2.5,0,0,4.2,0,7.1c0,2.1-0.6,3.7,4.2,8.7 C6.3,18,9.7,19.7,14,24c4.3-4.3,7.8-6,9.8-8.1C28.6,10.9,28,9.2,28,7.1z"/> </svg> <span> Home </span> </a> </li>

1 Answer

Figured it out!

Here's the code I used in case anyone else runs into the same issue:

header nav ul li:hover #nav-icon path { fill: #111; }