DEV Community

Cover image for CSS clamp() Method
damanita
damanita

Posted on

CSS clamp() Method

Hi there!

Recently, I've learnt a new functionality in CSS, which I've never known about before. I decided to share it with you, because I believe that it is very valuable and practical to use.

The clamp() method has three values. The first is the minimum, the second is the preferred and the third is the maximum value. This function allows you to set a value that will not decrease beyond the minimum and increase above the maximum, i.e. it clamps the middle value of the range. Below you will find a link to check it out:

https://jsfiddle.net/2kdbe680/2/

In my opinion, this is a very practical method, because you don't have to adjust font size to the screen size. It's a different approach to media query and depending on the situation might be very useful.

Do you have experience using it? Please drop a comment.

Thank you for reading!

Top comments (0)