Can I set min-width and max-width at the same time? Is this acceptable?
It is for my task for course but I don’t know that is this okay projects.I didn’t try it.
I don’t know that is this okay for real projects? Like is this okay for developers?
Can I set min-width and max-width at the same time? Is this acceptable?
It is for my task for course but I don’t know that is this okay projects.I didn’t try it.
I don’t know that is this okay for real projects? Like is this okay for developers?
2
Answers
Yes, it is perfectly acceptable to set both
min-width
andmax-width
properties on an element in CSS. In fact, it’s a common practice in web development, especially for creating responsive layouts.In this example, we have a .box element within a .container. The .box element has a minimum width of
200px
and a maximum width of400px
.for more best concept vist MDN Web Docs: max width …… min width
Yes, you can set both. This is usually used in responsive design so the content works both in small devices such as smartphones and big screen devices such as desktops, I really don’t see a problem.
Take a look at the w3schools explanations:
max-width
min-width
See this question if you want to learn more about their use in media queries.