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

Adriana Karlak
Adriana Karlak
1,450 Points

Why use 'p' as a descendant of the header element instead of a descendant of the address element?

From 0:36 - 1:30, he explains how to style all the paragraphs that are descendants of the header. But, why not instead style them as descendants of the address? The address element was closer, so isn't it the parent? Aren't the p elements direct descendants of the address element? Sorry, I'm probably not making much sense because I'm so tired. Basically, what I'm saying is how do you tell which is the parent element of what you're trying to style as a descendant? I thought it was the closest tag that it was nested in, which in this case is the address tag. So wouldn't you write it as 'address p' instead of 'header p'?

1 Answer

Hey Adriana

A descendant means that it can be nested anywhere within it in the DOM tree. It could be directly below it or it could be several levels deep.

Then there is the child combinator (accessed with >) which requires the element to be the next nested level down.

Hopefully this helps!

Adriana Karlak
Adriana Karlak
1,450 Points

Hi, Thanks for answering! I think I understand now. So does that mean he COULD have styled it as a descendant of the 'address' instead of the 'header' if he wanted to? And that it would still be correct and everything if he had done it that way instead?