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 trialRob Harding
4,128 PointsMin/max-width vs width
Whats the difference between min/max-width vs width?
3 Answers
Oğulcan Girginc
24,848 PointsHi,
Mozilla Developer Network's (MDN) definitions are quite good.
width:
The width CSS property specifies the width of the content area of an element. The content area is inside the padding, border, and margin of the element.
min-width:
The min-width CSS property is used to set the minimum width of a given element. It prevents the used value of the width property from becoming smaller than the value specified for min-width.
max-width:
The max-width CSS property is used to set the maximum width of a given element. It prevents the used value of the width property from becoming larger than the value specified for max-width.
Yulia Markina
12,616 PointsHi Rob, I can only add to Ogulcan's answer that min/max-width properties are essential when you're building a responsive website. It gives you control on displaying your content properly and predictable.
Shawn Denham
Python Development Techdegree Student 17,802 Pointswidth {50px; } - no matter what the width of the object is 50px
min-width {50px; } - the object HAS to be at least 50px.
max-width {50px; } - the absolute widest the object can be is 50px.
Basically said just exactly what Ogulcan posted, just summarized :)