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 CSS Layout Basics Controlling Layout with CSS Display Modes Positioning Elements Side-By-Side with Inline Display

Chris Gains
Chris Gains
2,888 Points

Targeting

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
Steven Parker
229,771 Points

A 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 */ }
Chris Gains
Chris Gains
2,888 Points

Thanks Steven, got it ;)

Kevin Korte
Kevin Korte
28,148 Points

Yes Chris, that behavior would be normal. Steven's response is correct.