Skip to content
Back to Concepts
CSS UniverseTrack 4: Units & MathMath Functions
1st Year CS Foundation ยท Core Track 4Core Concept 15

Math Functions: calc, min, max, clamp

Turn CSS into a dynamic mathematical engine. Mix units with calc() and create fluid responsive typography that scales across mobile and desktop with clamp().

1. The Core 4 Functions

Dynamic Math in Modern CSS

calc(...)

Mixes incompatible units like percentages and pixels!
width: calc(100% - 40px);

min(...)

Picks the smallest value in the comma-separated list.
width: min(100%, 800px);

max(...)

Picks the largest value in the list (sets safe minimums).
padding: max(16px, 2vw);

clamp(min, val, max)

The holy grail! Pins a fluid scaling value between a minimum and maximum threshold.

2. Live Fluid clamp() Studio

Simulate Viewport Scaling Across Devices

Mobile (320px)Simulated Screen: 768pxDesktop (1400px)
Fluid Typography
Active Computed Size: 31px
font-size: clamp(1.5rem, 4vw, 3.5rem);
- Under 600px screen: Locked at 1.5rem (24px)
- Between 600px and 1400px screen: Scales smoothly with 4vw
- Above 1400px screen: Capped safely at 3.5rem (56px)
Next in Track 4

16. CSS Variables (Custom Properties)

Design tokens, component scoping, and instant dark mode theme switching.

Continue to CSS Variables