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

Siddharth Pande
Siddharth Pande
9,046 Points

<img> CSS max width question

when the max-width property is set to 100% for an image in CSS then as the size of the browser window is decreased the width of the image decreases in proportion to it. Bus why the height of the image also adjusts according to it when no property for height adjustment is defined with CSS

1 Answer

Steven Parker
Steven Parker
231,046 Points

The default value for the height property is "auto", which causes the height to be set relative to the width to preserve the image aspect ratio.

You can easily change this behavior by setting an explicit value for height.

Siddharth Pande
Siddharth Pande
9,046 Points

thanks for such a quick reply.