CSS max() Function

CSS Update

The CSS max() comparison function allows to set the largest value from a set of given values. That can then be used as the value for the given CSS property name.

.responsive #text {
	font-size: max(2vw, 12px);

In the above example, we are trying to set a font size that is not rendered very small in mobile devices. Using max(), font size will be set as the bigger of 2vw & 12px.

max() can accept multiple comma separated values as parameters. Values can be in different units.

Browser Compatibility

Tutorials & Resources

March 30, 2020


Loading Comments