Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

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,965 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/.