Favorites

CSS <calc-sum> Data Type

<calc-sum>
CSS Data TypeThis data type is supported by all modern browsers.
Updated 21st November 2026

The <calc-sum> data type is a math expression of terms joined by + or -, which is what calc() and the other math functions accept.

☕
Enjoying this site?

Help keep it running with a small coffee donation. Every bit of support is appreciated!

Buy us a coffee

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

Bar
Demo Code
HTML Code
<div class="demo-track">
	<div class="demo-element">Bar</div>
</div>
CSS Code
.demo-track {
	width: 300px;
	padding: 8px 0;
	background: #f4f4f4;
	outline: 1px dashed #b0b0b0;
}
.demo-element {
	height: 36px;
	display: flex;
	align-items: center;
	padding: 0 8px;
	box-sizing: border-box;
	background: #4361ee;
	color: #fff;
	font-size: 12px;
	white-space: nowrap;
	width: calc(100% - 60px);
}

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

<div class="layout">
<aside class="sidebar">
Sidebar
<code>width: 200px</code>
</aside>
<main class="main">
Main column
<code>width: calc(100% - var(--sidebar) - var(--gap))</code>
<div class="tiles">
<div class="tile">tile</div>
<div class="tile">tile</div>
<div class="tile">tile</div>
</div>
<code>tile width: calc(2 * 3rem + 10px)</code>
</main>
</div>
/* Demonstrates  expressions in a simple layout */
* { box-sizing: border-box; }

body {
  margin: 24px;
  font-family: system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Arial;
  background: #f4f6f8;
  color: #0f172a;
}

.layout {
  --sidebar: 200px;
  --gap: 1rem;
  display: flex;
  gap: var(--gap);
  max-width: 900px;
  margin: 0 auto;
}

.sidebar,
.main {
  border-radius: 10px;
  padding: 16px;
  color: #fff;
  font-weight: 600;
}

.sidebar {
  width: var(--sidebar);
  background: #334155;
}

/* 100% minus the sidebar and the gap */
.main {
  width: calc(100% - var(--sidebar) - var(--gap));
  background: #2563eb;
}

.tiles {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 12px;
}

/* multiplication is evaluated before addition */
.tile {
  width: calc(2 * 3rem + 10px);
  height: calc(3rem + 10px);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.25);
  display: grid;
  place-items: center;
  font-size: 12px;
}

code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, monospace;
  font-size: 12px;
  font-weight: 400;
  display: block;
  margin-top: 6px;
  opacity: 0.9;
}
Open in editor

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.

This data type is supported by all modern browsers.

Desktop

Chrome
Edge
Firefox
Opera
Safari

Tablets & Mobile

Chrome Android
Firefox Android
Opera Android
Safari iOS
Samsung Internet
Android WebView
-
Supported Unknown Not supported
☕
Enjoying this site?

Help keep it running with a small coffee donation. Every bit of support is appreciated!

Buy us a coffee