sqrt() CSS Function
The sqrt() function returns the square root of a number, such as sqrt(16), which is 4.
Description
The sqrt() CSS function returns the square root of a number: the value that, multiplied by itself, gives the argument. For example, sqrt(16) is 4. The argument must be a plain <number> and the result is also a number, so you multiply it by a unit when you need a length. Negative numbers return NaN.
A practical use is sizing shapes by area rather than by width. If you want one square to have twice the area of another, its side must be sqrt(2) times as long, not twice as long. The same idea applies to circles in charts and bubble graphs, where the area should represent the data value so large values are not visually exaggerated.
/* Squares whose areas are 1x, 2x and 4x a base square */
.sq-1 { width: calc(sqrt(1) * 60px); aspect-ratio: 1; }
.sq-2 { width: calc(sqrt(2) * 60px); aspect-ratio: 1; } /* about 84.9px */
.sq-4 { width: calc(sqrt(4) * 60px); aspect-ratio: 1; } /* 120px */
/* Bubble chart where area matches the value */
.bubble {
width: calc(sqrt(var(--value)) * 10px);
}
sqrt() is equivalent to pow(x, 0.5) and belongs to the exponential function family with hypot(), log() and exp().
Interactive Demo
Syntax
sqrt() = sqrt( <calc-sum> )
Values
- <calc-sum>A calculation resolving to a <number>. The function returns its square root as a <number>.
Example
Browser Support
The following information will show you the current browser support for the CSS sqrt() function. Hover over a browser icon to see the version that first introduced support for this CSS function.
Desktop





Tablets & Mobile





