More Than Calc

Modern CSS got functions that were previously only in programming languages.

  • round(strategy, value, step): rounding (e.g., to nearest integer or multiple of 10).
  • mod() and rem(): remainder of division.
  • abs(): absolute value (number without minus).

Why Is This Needed?

For example, so font size is always multiple of 4 for perfect vertical rhythm:

h1 {
  font-size: round(up, 2.3rem, 4px);
}
Note

These functions allow creating ultra-precise layout that adapts to any conditions with mathematical precision.