CSS <calc-sum> Data Type
The <calc-sum> data type is a math expression of terms joined by + or -, which is what calc() and the other math functions accept.
Description
The <calc-sum> CSS data type represents an expression made of one or more terms joined by addition (+) or subtraction (-). It is the top-level grammar for the contents of CSS math functions: whatever you write inside calc(), and each argument of functions such as min(), max(), clamp(), abs(), round() and sin(), is a <calc-sum>.
A <calc-sum> is built from smaller pieces. Each term is a <calc-product>, which is a series of values joined by multiplication (*) or division (/). Each value inside a product is a <calc-value>: a <number>, a <dimension>, a <percentage>, a <calc-keyword>, another math function, or a nested <calc-sum> in parentheses. This structure is what gives multiplication and division a higher priority than addition and subtraction, just like ordinary arithmetic.
Two rules are worth remembering. First, the + and - operators must have whitespace on both sides. calc(100% - 20px) is valid, but calc(100%-20px) is not, because -20px would be read as a negative number. Second, all the terms being added or subtracted must resolve to the same type: you can add a length to a percentage that resolves to a length, but you cannot add a length to a time.
Examples:
/* Main column fills what the sidebar and gap leave */
.main {
width: calc(100% - 240px - 2rem);
}
/* Products inside a sum are evaluated first */
.tile {
height: calc(2 * 3rem + 10px);
}
/* Parentheses create a nested calc-sum */
.offset {
margin-left: calc((100vw - 960px) / 2);
}
/* Each argument of clamp() is a calc-sum */
h1 {
font-size: clamp(1.5rem, 1rem + 2vw, 3rem);
}
You rarely need to name <calc-sum> directly, but understanding it explains why spacing around operators matters and how CSS decides the order of operations.
Interactive Demo
Syntax
<calc-sum> = <calc-product> [ [ '+' | '-' ] <calc-product> ]* where <calc-product> = <calc-value> [ [ '*' | '/' ] <calc-value> ]* <calc-value> = <number> | <dimension> | <percentage> | <calc-keyword> | ( <calc-sum> )
Values
- <calc-product>A term made of one or more <calc-value> items joined by the * (multiply) or / (divide) operators. When multiplying, at least one side must be a <number>; when dividing, the right-hand side must be a <number>.
- +Adds two terms together. It must be surrounded by whitespace, and both terms must resolve to the same type.
- -Subtracts the right-hand term from the left-hand term. It must be surrounded by whitespace, and both terms must resolve to the same type.
- <calc-value>A single value inside a product: a <number>, a <dimension>, a <percentage>, a <calc-keyword>, a math function, or a nested <calc-sum> inside parentheses.
Example
Browser Support
The following information will show you the current browser support for the CSS calc-sum data type. Hover over a browser icon to see the version that first introduced support for this CSS data type.
Desktop





Tablets & Mobile





