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 trialChris Gains
2,888 PointsTargeting
Hi this question (I think) is to confirm something I had missed before. I noticed it when Guil was trying to get the nav to display on one line. I thought for example if I targeted .main-nav li then the change would occur on both .main-nav and li. But this doesnt seem the case, only the li is targeted.
Is that correct or am I getting things mixed up?
2 Answers
Steven Parker
231,269 PointsA simple CSS selector targets only one kind of thing. In this case, .main-nav li
targets list items which are descendants of an element (of any type) with class main-nav.
If you want a rule to apply to more things, you can combine selectors with commas. For example, to target both the elements with class main-nav and the list items they contain, you could use:
.main-nav, .main-nav li { /* properties and values here */ }
Kevin Korte
28,149 PointsYes Chris, that behavior would be normal. Steven's response is correct.
Chris Gains
2,888 PointsChris Gains
2,888 PointsThanks Steven, got it ;)