Home
CSS
CSS Math Functions
Tryit: Using the min() 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: min(50%, 300px); } </style> </head> <body> <h1>The min() Function</h1> <p>Use min() to set the width of #div1 to whichever value is smallest, 50% or 300px:</p> <div id="div1">Some text...</div> <p>Resize the browser window to see the effect.</p> </body> </html>