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 trialDylan Carter
4,780 PointsI don't get what the difference is in using the > for children instead of just putting a space like we were doing?
Before when, say, i wanted to affect a p inside of the header i would use " header p { css:css; } "
what is the difference between that and doing..
" header > p { css:css; } "
3 Answers
Mohamed Nasser
5,316 PointsThe difference is that when you use header > p { css:css; } you are targeting the p element who are direct children to header that means if you had a code like this
<header> <p>Paragraph 1</p> <p>Paragraph 2</p> <div> <p>Paragraph 3</p> <div> <p>Paragraph 4</p> </div> </div> </header>
The selector header > p { css:css; } will only target Paragraph 1 and Paragraph 2 .... the selector header p { css:css; } will target all the Paragraphs 1,2,3 and 4
Saqib Ali
3,686 PointsThought I'd just make the html clearer and practise some code markup.
header > p { css:css; }
<header>
<p>Paragraph 1</p>
<p>Paragraph 2</p>
<div>
<p>Paragraph 3</p>
<div>
<p>Paragraph 4</p>
</div>
</div>
</header>
ywang04
6,762 PointsHope this helps.
Dylan Carter
4,780 PointsDylan Carter
4,780 PointsOHHH okay i get it the > is for direct children while just the space could be a child of it at any level if you will. thank you.
Dylan Carter
4,780 PointsDylan Carter
4,780 PointsOHHH okay i get it the > is for direct children while just the space could be a child of it at any level if you will. thank you.