Encodera

Thanks for reading!

Donate to the site — we work hard for you.

HTML & CSS reference

max()

Takes the largest of the values — a way to set a lower limit.

Syntax

max(value, value, …)

Parameters

ParameterTypeDescription
valueslengthTwo or more values separated by commas.

Examples

A minimum size that grows with the window:

<p style="font-size: max(16px, 1vw); padding: max(8px, 2vw); background: honeydew;">At least 16px text and 8px padding, more on wide screens</p>

Notes

max() sets the minimum: the value never drops below the largest argument. For both limits at once, use clamp().

See also

  • min() — Takes the smallest of the values — a way to set an upper limit.
  • clamp() — Keeps a value within limits: the preferred value, but not less than the minimum and not more than the maximum.
  • min-width — The minimum width: the element cannot become narrower.

In the tutorial

  • CSS functions — Calculations right in CSS — calc(), min(), max() and clamp(), mixing units, fluid sizes and functions together with variables.

Thanks for reading!

Donate to the site — we work hard for you.