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 trialAntonio Fran
3,965 PointsWhen should I use min-width and when width, when it comes to setting width of elements?
I am currently on "How to make a website" course and I have noticed that min-width CSS property seems to be more preferred than only width property when setting width of elements.
It is said that it is to avoid an element to end up having lower width then specified min-width. However, I don't see the point to use min-width with fixed values, only relative values. Aren't min-width:50px and width:50px gonna give pretty much same result?
Anyway, can you provide some set of rules that will help me define when should I use min-width and when width, when it comes to setting width of elements?
1 Answer
Michael Caveney
50,144 PointsThe first thing that pops into my head is that min-width is very useful when you're utilizing responsize design (which you should be!), and you absolutely, positively don't want certain elements wrapping or shrinking too much.