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 trialSam Katz
2,986 Pointswhat is the difference between max-width and min-width? how do I say less than 1200px?
what is the difference between max-width and min-width? how do I say less than 1200px?
4 Answers
Ravi kumar
1,395 PointsHey! Well! media-query is the property of the elements that define the size of the element in different screen sizes such as Smartphone, PC, Laptop and ultrawide screens.
where max-width define the maximum size of the element which could be presented on the screen. Ex: if you wanna define the max-width of the element then you will say @media-queries (max-width: 1200) that means element size shouldn't go more than 1200px.
In a similar way, min-width is the minimum size of the element which could be presented on the screen. Ex: if you wanna define the min-width of the element then you will say @media-queries (min-width: 1200) that means element size wouldn't go less than 1200px.
Hope I would have solved your media query. Any suggestions and corrections will be highly appreciated.
Grant Polhemus
7,093 PointsWriting it out this way helped me to understand it. Hope it helps someone else.
(max-width: 1200px) means ... styles apply if the browser window is ≤ 1200px
(min-width: 1200px) means ... styles apply if the browser window is ≥ 1200px
(min-width: 800px) and (max-width: 1200px)
means ... styles apply ONLY if the browser window is 800px ≥ AND ≤ 1200px. As soon as the browser hits 799px or 1201px the styles in the @media rule will not be applied.
tomaszfurmanczyk
Full Stack JavaScript Techdegree Student 18,242 PointsFor instance: /* Target viewport sizes less than 1200px */
Max-width: means less @media (max-width: 1199px)
Min-width: means more @media (min-width: 1200px)
Abiel Ortega
2,171 Pointsmin-width is the smallest with the element can go. Let's say you're making an interactive webpage for people that view your site on their phones you can set the min-width and give it a value that doesn't go any lower than a certain percentage or px size. Same for max-width but it's for the max amount of width that an element can have for people that are viewing your website on ultrawide monitors or also if you don't want an element to go over a certain width size you may also use it for that.
if you are trying for your element to not go over 1200px then use the max-width, if you're trying to make 1200px the smallest size for the element to go then use min-width so it doesn't go any lower than 1200px.