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

Suban Purushothmakumar
Suban Purushothmakumar
3,306 Points

Do children of children elements become flex items as well?

In the video you mentioned that only the direct child/children of the flex container become flex items. Do child elements within direct child elements also become flex items?

For example: <div class="flexcontainer"> <div class="childClass"> <div class="childOfChildClass"> </div> </div </div

So in the above example does the childOfChildClass become flex item as well?

1 Answer

Steven Parker
Steven Parker
229,744 Points

Only direct children of flex containers are flex items.

In your example, "childOfChildClass" would only be a flex item if "childClass" was a flex container. It's allowed for an element to be both a flex item and a flex container, but it would require specific CSS to set its "display" property to "flex" for that to happen.