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 CSS: Cascading Style Sheets Center the Wrapper

Anthony Rice
Anthony Rice
7,976 Points

The images within the div wrapper

I do not understand why the images are not contained within the boundaries of the orange background. From my understanding, since the wrapper div is specified as having a max with of 940px, I assumed that all elements contained within the div element would have to follow that same property, thus, the images could not exceed 940px.

3 Answers

Shane Oliver
Shane Oliver
19,977 Points

Your image doesn't have a width property set, so it will display at it's full size. the reason it is coming out of the div is because the div doesn't have it's overflow set to hidden. Changing the img width to 100% will keep the image contained in the div wrapper

Rishabh Ahuja
Rishabh Ahuja
747 Points

there is a more simple method as the image tag inside the div tag and div tag has max width of 940px adding max-width inherit to img tag , its width will be inherited from the wrapper this is will be usefull in media queries which is further taught

Anthony Rice
Anthony Rice
7,976 Points

Thanks for the explanation Shane. The overflow property has not been taught yet, but if anyone is looking for additional details, I found a great reference at https://css-tricks.com/almanac/properties/o/overflow/.