CSS max() Function

Definition and Usage

CSS max() The function selects the largest value from the list of comma-separated values as the attribute value.

Example

Use max() Set the width of #div1 to at least 300px, but if the viewport width exceeds 600px, the width will be wider (50%):

#div1 {
  background-color: yellow;
  height: 80px;
  width: max(50%, 300px);
}

Try It Yourself

CSS Syntax

max(value1, value2, ...)
Value Description
value1, value2, ... Required. A list of comma-separated values, from which the largest value is selected.

Technical Details

Version: CSS Values and Units Module Level 4

Browser Support

The numbers in the table indicate the first browser version to fully support this function.

Chrome Edge Firefox Safari Opera
79 79 75 11.1 66

Σχετικές σελίδες

Αναφορά:Συνάρτηση CSS min()

Εκμάθηση:Μαθηματικές συναρτήσεις CSS