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 How to Make a Website Styling Web Pages and Navigation Make a CSS Image Gallery

Parent Element

I don't remember this being discussed in the course.

I am stuck on the challenge

Add CSS that will allow all images to fill their parent element.

Bummer! You set the maximum width for images, but it doesn't look like they're filling their parent elements.

img { max-width: 940px;

}

3 Answers

Ethan Lowry
PLUS
Ethan Lowry
Courses Plus Student 7,323 Points

I have not checked the particular challenge in question but perhaps this is what's needed?

img{
    display: block;
    max-width: 100%;
}

"display: block" causes an element to fill up the entire width of its parent element.

This code worked but I find it odd that it wasn't included in the study video .

Thank you

This code worked but I find it odd that it wasn't included in the study video .

Thank you

Ethan Lowry
Ethan Lowry
Courses Plus Student 7,323 Points

It would be unusual if the required answer was not included anywhere in the video so it's possible you missed a step somewhere else that would have made display:block unnecessary, however I can't say. Glad this helped anyway.

Cameron Cottle
Cameron Cottle
13,742 Points

The question is a tad confusing, it is looking for max-width: 100%; but the way it's phrased makes me think that I need to set the width: 100%;

Did that as well but it still says they're not filling the parent elements

I don't even know what a Parent element is yet

Cameron Cottle
Cameron Cottle
13,742 Points

A parent element is the an element that the tag in question is nested in.

<div class="parent-element">
   <div class="child-element"></div>
</div>

Anything nested in an element is likewise referred to as a child.