liveBook · Manning

Calc()

The CSS calc() function evaluates an arithmetic expression involving compatible CSS values and units to produce a computed value.

How 3 Manning books explain it

Math for Web Design

calc() is a CSS mathematical function that evaluates an arithmetic expression, including compatible units, to produce a computed style value.

How it is used
Expresses responsive layout and font-size relationships directly in CSS rather than hardcoding measurements for each screen size.
How deep it goes
Works through unit conversion and computed layout values, then specifies syntax, compatible types, scalar operands, and operator precedence.
Examples
Uses a viewport-sized dialog with breathing room, a percentage-minus-rem width, three columns with gutters, and a fluid font-size formula.
What you can do after
Applies it via CSS declarations to calculate responsive widths, gutters, dialog limits, and font sizes.

Read how Math for Web Design explains calc() →

Tiny CSS Projects

The CSS calc() function computes a property value from arithmetic expressions involving CSS values and units.

How it is used
Uses arithmetic to size card containers and position overlapping images without hard-coding every resulting value.
How deep it goes
Explains subtraction, division, multiplication, negative results, and custom-property reuse through two worked card layouts.
Examples
Demonstrates card height subtraction, grid rows, image overlap, negative margins, and spacing that prevents clipping on short screens.
What you can do after
Apply calc() to build flexible card dimensions and image offsets that respond to available space and reusable size variables.

Read how Tiny CSS Projects explains calc() →

CSS in Depth, Second Edition

The CSS calc() function computes a value from arithmetic involving CSS values and units.

How it is used
Combines responsive viewport sizing with relative units and replaces magic-number dimension adjustments.
How deep it goes
Defines four arithmetic operators, explains whitespace requirements, and demonstrates responsive font and variable-based width calculations.
Examples
Uses responsive root typography and a column width reduced by its combined horizontal padding.
What you can do after
Apply calc() to build smoothly scaling font sizes and derive widths from variables instead of unexplained constants.

Read how CSS in Depth, Second Edition explains calc() →

What to know first

Related concepts

Questions about calc()

What is calc()?

The CSS calc() function evaluates an arithmetic expression involving compatible CSS values and units to produce a computed value.

Which Manning books explain calc()?

Math for Web Design, Tiny CSS Projects and CSS in Depth, Second Edition.

What should I know before learning calc()?

Manning books that teach calc() usually introduce em and proportion first.

What is calc() a kind of?

Calc() is a kind of CSS math function. A CSS math function is a built-in CSS function that evaluates mathematical values or expressions in style declarations.

These guides are generated from the text of Manning books by Manning's knowledge graph and link to the sections they draw on. The full books are available on liveBook and at manning.com.