W3cubDocs

/CSS

sqrt()

The sqrt() CSS function is an exponential function that returns the square root of a number.

The function pow(x, 0.5) is equivalent to sqrt(x).

Syntax

/* A <number> value */
width: calc(100px * sqrt(9)); /*  300px */
width: calc(100px * sqrt(25)); /*  500px */
width: calc(100px * sqrt(100)); /* 1000px */

Parameters

The sqrt(x) function accepts only one value as its parameter.

x

A calculation which resolves to a <number> greater than or equal to 0.

Return value

Returns a <number> which is the square root of x.

  • if x is +∞, the result is +∞.
  • If x is 0⁻, the result is 0⁻.
  • If x is less than 0, the result is NaN.

Formal syntax

<sqrt()> = 
sqrt( <calc-sum> )

<calc-sum> =
<calc-product> [ [ '+' | '-' ] <calc-product> ]*

<calc-product> =
<calc-value> [ [ '*' | '/' ] <calc-value> ]*

<calc-value> =
<number> |
<dimension> |
<percentage> |
<calc-constant> |
( <calc-sum> )

<calc-constant> =
e |
pi |
infinity |
-infinity |
NaN

Specifications

Browser compatibility

Desktop Mobile
Chrome Edge Firefox Internet Explorer Opera Safari WebView Android Chrome Android Firefox for Android Opera Android Safari on IOS Samsung Internet
sqrt No No 112 No No 15.4 No No 112 No 15.4 No

See also

© 2005–2023 MDN contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-US/docs/Web/CSS/sqrt