user13397022
user13397022

Reputation:

What's the difference between minmax() and clamp() in CSS?

Both CSS functions clamp the value between an upper and lower bound.

The only difference that I know is that minmax() can only be used in CSS grid.

Upvotes: 3

Views: 5599

Answers (2)

clay
clay

Reputation: 1877

minmax() may only be used in Grid and picks between two (2) parameters.

clamp() can be used anywhere in CSS and picks between three (3) parameters: minimum, preferred, and maximum, selecting the middle (preferred) parameter when possible.

Upvotes: 8

biberman
biberman

Reputation: 5767

From developer.mozilla.org:

clamp() enables selecting a middle value within a range of values between a defined minimum and maximum. It takes three parameters: a minimum value, a preferred value, and a maximum allowed value.

minmax() only accepts the two extreme values, plus the difference that you already mentioned.

Upvotes: 2

Related Questions