CSS Functions Reference

Every CSS function with accepted arguments, return type and browser support.

A searchable reference for CSS functions including calc(), clamp(), min(), max(), var(), env(), color-mix() and transform functions, with arguments, what each returns and browser support.

When do I need calc() instead of plain math?

calc() is required whenever you combine different units — like calc(100% - 2rem) — because CSS cannot otherwise add a percentage to a fixed length. It is also handy for keeping arithmetic readable when mixing custom properties and constants.

This is a searchable reference for CSS functions — the parenthesised keywords that compute a value rather than naming a fixed one. It covers the math family (calc(), clamp(), min(), max(), trig and exponential functions), value references (var(), env(), attr()), color functions (rgb(), oklch(), color-mix()), gradients, transforms, grid track functions and easing curves.

How it works

A CSS function is a keyword immediately followed by parentheses containing comma-separated arguments. The engine evaluates the function at computed-value time and substitutes the result wherever the function appears. Functions are typed: calc() and the math functions return a length, number, angle or time depending on their inputs; rgb() and friends return a color; linear-gradient() returns an image; the translate()/scale() family returns a transform. Many functions nest — you can wrap a var() inside a clamp() inside a calc() — as long as the units stay compatible within each arithmetic expression. The newer math functions (round(), mod(), sin(), pow(), hypot()) let you do real trigonometry and rounding directly in the stylesheet.

Tips and gotchas

clamp(min, preferred, max) is the workhorse for responsive sizing; pair a rem floor and ceiling with a vw-based preferred value for fluid type. color-mix() reads best in a perceptual space such as oklch or oklab. var() takes an optional fallback as its second argument, used only when the property is genuinely unset. Watch division and multiplication in calc(): you may only divide by a plain number, and at least one operand of a multiplication must be unitless.

Example

:root { --gap: 1rem; }

.title {
  font-size: clamp(1.5rem, calc(1rem + 3vw), 3rem);
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(12rem, 1fr));
  gap: var(--gap, 1rem);
}

.tint { background: color-mix(in oklch, royalblue 70%, white); }

Everything runs in your browser; nothing you search is uploaded.