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 CSS Basics (2014) Basic Layout Floats

J V
J V
3,414 Points

Why do we have to set max-width for 'img' header in order for the width to adjust properly in the 'resort/tips' classes?

Here is the portion of the CSS code:

img { max-width: 100%; margin-bottom: 20px; }

.resorts, .tips { width: 46.5%; }

If I comment out img value max-width: 100%; then the image width does not adjust to 46.5%. Why is this the case?

1 Answer

Jake Lundberg
Jake Lundberg
13,965 Points

Because you have to specifically tell the image to fill 100% of the width of the containing element. If you comment that out the image assumes its default size (the size of the actual image).

J V
J V
3,414 Points

Hi Jake,

Thank you for answering.