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

What is the difference between .button and .photo-overlay:hover .button?

Aren't they both targeting .button?

3 Answers

Steven Parker
Steven Parker
231,261 Points

Yes, they both target the "button" class element(s), but the settings in the ".photo-overlay:hover .button" rule are only applied to that class while the cursor is over the parent element that has the class "photo-overlay".

On the other hand, ".button:hover" would apply the class while the cursor is over the button itself.

Thank you, Steven but I meant to write: "What is the difference between .button:hover and .photo-overlay:hover .button?"

Thank you, Steven! It makes sense now.