Home
CSS
CSS Math Functions
Tryit: Using the max() function
Run ❯
Get your
own
website
Result Size:
625 x 534
×
Change Orientation
Save Code
Change Theme, Dark/Light
Go to Spaces
<!DOCTYPE html> <html> <head> <style> #div1 { background-color: yellow; height: 100px; width: max(50%, 300px); } </style> </head> <body> <h1>The max() Function</h1> <p>Use max() to set the width of #div1 to whichever value is largest, 50% or 300px:</p> <div id="div1">Some text...</div> <p>Resize the browser window to see the effect.</p> </body> </html>