With min and max properties, we can limit element sizes. This ensures that an element does not become too small or too large, even if the parent container size changes.
The min-width, max-width, min-height, and max-height settings provide fine-tuning for layouts. They are often used in creating responsive design.
| Property | Description |
|---|---|
| min-width | Sets the minimum width that the element cannot go below. |
| max-width | Sets the maximum width that the element cannot grow beyond. |
| min-height | Sets the minimum height that the element cannot go below. |
| max-height | Sets the maximum height that the element cannot grow beyond. |
In the following example, the box has both minimum and maximum width and height.
The red box can be between 200 and 400 pixels wide, and between 100 and 200 pixels tall.
Min and max values combined with percentage widths are excellent for responsive layouts.
Min and max properties help prevent extreme shrinking or stretching of elements.
✨ Ask Lara — your AI study partner
Unlock personalized learning support. Lara can explain lessons, summarize topics, and answer your study questions — available from the Go plan and above.
Lara helps you learn faster — exclusive to ReadyTools Go, Plus, and Max members.