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 trialMichael Barnette
614 PointsParent 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
Courses Plus Student 7,323 PointsI 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.
Cameron Cottle
13,742 PointsThe 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%;
Michael Barnette
614 PointsDid 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
13,742 PointsA 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.
Michael Barnette
614 PointsMichael Barnette
614 PointsThis code worked but I find it odd that it wasn't included in the study video .
Thank you
Michael Barnette
614 PointsMichael Barnette
614 PointsThis code worked but I find it odd that it wasn't included in the study video .
Thank you
Ethan Lowry
Courses Plus Student 7,323 PointsEthan Lowry
Courses Plus Student 7,323 PointsIt 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.