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 Style the Portfolio

i need help with the portion of CSS that will allow all images to fill their parent element.

In the portion of the How to Make a Website I'm having issue understanding what the question is asking me to do where it says "Add CSS that will allow all images to fill their parent element."

3 Answers

Don Shipley
Don Shipley
19,488 Points

With what Benjamin is saying lets say you have an image that is 980px wide another 1025px wide. In the video he stats to use max-width to be 100%

In your css file you would write img{ max-width:100%;}

if the image was in a div tag at 450px the image would only go 450px wide.

Benjamin Harrison
Benjamin Harrison
10,958 Points

Assuming you are using an image with an explicit height and width (not all do) then when added to your page without CSS guidance it will be that size. What you are being asked to do is use CSS to override the picture's width and height values so that they fill up the parent element.

Thanks! I got it:)