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

Isaac Coleman
Isaac Coleman
466 Points

I dont understand how to set the parent element on a picture

please help me. I can not figure out the how to set the parent elements on my pictures. i have tried what he did in the video and still do not understand.

2 Answers

You should set maximum width of all images to 100%.

img{
 max-width: 100%; 
}

The above code snippet will set maximum width for all images to 100 percent. Meaning it will fill their parent complete.

If parent element is 200px width then image will be 200px width.

I hope it helps.

You also need to make sure the image is nested in the correct element so that your CSS code is applying the correct styling for the image.

If you have problems, code and a screenshots will help us figure out the problem. Don't be afraid to ask many questions.