What is the difference between max-width and min-width? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 2

What is the difference between max-width and min-width?

When/how do we use this property?

17th Sep 2017, 3:07 AM
Feelc
7 Answers
17th Sep 2017, 4:07 AM
Amethyst Animion
Amethyst Animion - avatar
+ 5
max-width is maximum width min-width is minimum width i'll be back, please wait, i want to give an example code
17th Sep 2017, 3:52 AM
Amethyst Animion
Amethyst Animion - avatar
+ 5
@media only screen and (max-width: 599px) { body { background: green; } } @media only screen and (min-width: 600px) { body { background: blue; } } copy code above to css section when your screen width below or same to 599px, the bgcolor will be green when your screen width above or same to 600px, the bgcolor will be blue
17th Sep 2017, 4:42 AM
Amethyst Animion
Amethyst Animion - avatar
+ 3
minimum means that the value cannot be less than that... It has to be either that value or more than that.. Maximum means that the value cannot exceed that value.. It has to be either less than or equal to that value.. Eg:- if min-width : 20px...it mean that width cannot be less than 20px max-width: 100px.. It mean that width cannot be more than 100px Hope you got it. 👍
17th Sep 2017, 5:15 AM
Omniscient
Omniscient - avatar
+ 1
@JFS Animion Thank you for your response but I'm still in doubt about the min-width. If you don't mind, can you explain it in other way?
17th Sep 2017, 4:20 AM
Feelc
+ 1
Thank you very much guys, now it all makes sense. This is why this is usually used in a responsive layout/design in many websites.
17th Sep 2017, 5:57 AM
Feelc
0
Width is resize according to the parent element size
14th Feb 2019, 5:08 AM
Amirali Shadi
Amirali Shadi - avatar