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 trialSylvester Hofstra
12,022 PointsCan someone tell me the difference between this two selectors?
What is the difference between:
gallery li a p {}
and
gallery p {}
It seems to do the same thing when I preview my workspace, but in the video he uses the first selector.
1 Answer
Tsenko Aleksiev
3,819 PointsIn "gallery" find all the "li"-s, find of there is an "a" in those "li"-s, now find all the "p"-s and apply css rules to those "p"-s. The other one is find all the "p" inside "gallery" and apply the css to those, no matter if the "p" is inside "li" and "a" or not. The first one is more concrete to apply the rule to and only to the "p"-s inside the list items and inside an anchor tag. Got it? :)
Sylvester Hofstra
12,022 PointsSylvester Hofstra
12,022 PointsHah, yeah I got it. Didn't see the difference at first, because all the "p"-s inside "gallery" are in "a"-s who are in "li"-s. So in my case it doesn't make a difference, but in other code it can. Thnx!