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![](https://ecs-static.teamtreehouse.com/assets/views/marketing/shared/community-banner-white-47072046c51352fe6a69f5e691ff5700b28bb11d45197d7bdf066d9ea3f72d0c.webp)
![Janina Alvarez](https://secure.gravatar.com/avatar/262e5d41fa20bc554f9b30965733b54a?s=96&d=https%3A%2F%2Fecs-static.teamtreehouse.com%2Fassets%2Fcontent%2Fdefault_avatar-445fbbabfc8dc9188fb5967fe43322ee0c3e0dd1e10f378bf8343784af5a13eb.webp&r=pg)
Janina Alvarez
Courses Plus Student 7,917 Points"Eat" Animation -- Why is the animation being applied to the "monster" class?
From what I understand, #eat:target
should be applying the animation/:target styling to the link element whose id is "eat". Instead, the animation is getting applied to the "monster" div. Why is that the case?
3 Answers
![Janina Alvarez](https://secure.gravatar.com/avatar/262e5d41fa20bc554f9b30965733b54a?s=96&d=https%3A%2F%2Fecs-static.teamtreehouse.com%2Fassets%2Fcontent%2Fdefault_avatar-445fbbabfc8dc9188fb5967fe43322ee0c3e0dd1e10f378bf8343784af5a13eb.webp&r=pg)
Janina Alvarez
Courses Plus Student 7,917 PointsHey Travis Alstrand , my bad , I thought I asked this question from the lesson directly 😅
It's from the :target and :root element lesson in CSS Selectors course: https://teamtreehouse.com/library/css-selectors/root-and-target
This is the codepen I'm referring to: https://codepen.io/Guilh/pen/QwvxOp
![Travis Alstrand](https://uploads.teamtreehouse.com/production/profile-photos/11658224/micro_travis.jpg)
Travis Alstrand
Data Analysis Techdegree Graduate 49,407 PointsWell you are correct, it is being applied to the div with the class of monster
, but this is actually the same div that holds the id of eat
.
And as Guil says at 3:03 of the video you shared, when clicking a link, if an element's id
matches the href of the link, it will take on the styles defined in the :target
selector rule.
I hope this helps clear things up!
<div id="eat" class="monster"></div>
<a href="#eat">Eat</a>
<a href="#">Stop Eating</a>
![Janina Alvarez](https://secure.gravatar.com/avatar/262e5d41fa20bc554f9b30965733b54a?s=96&d=https%3A%2F%2Fecs-static.teamtreehouse.com%2Fassets%2Fcontent%2Fdefault_avatar-445fbbabfc8dc9188fb5967fe43322ee0c3e0dd1e10f378bf8343784af5a13eb.webp&r=pg)
Janina Alvarez
Courses Plus Student 7,917 PointsAhhh that makes sense, thank you!! I got confused because I automatically associated the '#eat' in the CSS with #eat (the href attribute value for the link) in the HTML--- even though # in CSS actually refers to ID in html 😅
Thank you for clearing that up!
![Travis Alstrand](https://uploads.teamtreehouse.com/production/profile-photos/11658224/micro_travis.jpg)
Travis Alstrand
Data Analysis Techdegree Graduate 49,407 PointsVery understandable! You're very welcome, I'm glad it cleared things up for you
Travis Alstrand
Data Analysis Techdegree Graduate 49,407 PointsTravis Alstrand
Data Analysis Techdegree Graduate 49,407 PointsHey Janina Alvarez !![:wave: :wave:](https://image-proxy-cdn.teamtreehouse.com/28584d580caa0add1b6e73bd2b566abfc7521414/68747470733a2f2f7374617469632e7465616d74726565686f7573652e636f6d2f696d616765732f656d6f6a692f756e69636f64652f31663434622e706e67)
I'm not familiar with what video or course this is in reference too. Could you provide a link to the video you're on please?