CSS max() Function
Example
Use max() to set the width of #div1 to at least 300px, but wider (50%) if the viewport width is more than 600px wide:
#div1 {
background-color: yellow;
height: 80px;
width: max(50%, 300px);
}
Try it Yourself »
Definition and Usage
The CSS max()
function will use the largest value, from a comma-separated list of
values, as the property value.
Version: | CSS Values and Units Module Level 4 |
---|
Browser Support
The numbers in the table specify the first browser version that fully supports the function.
Function | |||||
---|---|---|---|---|---|
max() | 79 | 79 | 75 | 11.1 | 66 |
CSS Syntax
max(value1, value2, ...)
Value | Description |
---|---|
value1, value2, ... | Required. A list of comma-separated values - where the largest value is chosen |
Related Pages
CSS reference: CSS min() function.
CSS tutorial: CSS Math Functions.