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

HTML How to Make a Website Styling Web Pages and Navigation Make a CSS Image Gallery

Matthew Ashman
Matthew Ashman
4,364 Points

"Add CSS that will fit images to fill their parent element" I have no idea what this even is asking of me?

Can somebody please help me understand what it means for images to fill their parent element?

This question is a code challenge from the "How to Make a Website" course/Front-End Dev. Track.

Following along, we have been calling the gallery id: #gallery id{ } and setting up the images so that they show in two columns. However, I do not recall learning about filling parent elements - or at least do not understand the concept of doing so. Thank you.

1 Answer

Jason Anders
MOD
Jason Anders
Treehouse Moderator 145,860 Points

Hey Matthew. Welcome to Treehouse.

The challenge is asking you to target the images and have them fill the parent element. Images on their own, would need to be inside of a 'parent element' (i.e. a div). In the CSS rule, you just want to tell it that you want the image to expand to 100% of the parent. Therefore, the CSS would be targeting the img tag and using the max-width property:

img {
  max-width: 100%;
}

Hope this helps to make sense. Keep Coding! :smiley: