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 trialShakran Mushtaq
Front End Web Development Techdegree Student 611 Pointsif you set a max width does it automatically tell the browser to let the width get smaller if the screen size is smaller
because i tried it just by putting width instead of max width and the div area did not adjust to the screen size when made smaller, does this mean max width automatically tells the browser to minimize the width along with the screen size?
2 Answers
Jacob Herrington
15,835 PointsMax-width simply restricts the maximum width an element can have - it has nothing to do with resizing the window.
Here is a JSFiddle demonstrating what the Max-width CSS rule does.
Jason Anello
Courses Plus Student 94,610 PointsHi Shakran,
In this project the wrapper div was set to a max-width of 940px.
What this means is that the wrapper could never be more than 940px wide but it could be less.
If the browser width was 1300px wide, then the wrapper div would be restricted to 940px.
If the browser width was 780px wide, then the wrapper div would shrink to 780px.
Below 940px it will take up as much width as it can.
I'm neglecting padding and margins here but this is the overall idea.
Shakran Mushtaq
Front End Web Development Techdegree Student 611 PointsShakran Mushtaq
Front End Web Development Techdegree Student 611 Pointshi then why when max width was set the #wrapper resized with the window