# hypot()

> The `hypot()` CSS math function returns the square root of the sum of the squares of its arguments, like the hypotenuse length of a right-angled triangle.

## How do I calculate the distance between two points in CSS?

The math function that calculates the length of the hypotenuse of a right-angled triangle. It takes two or more numbers as arguments, representing the sides of the triangle and returns the square root of the sum of their squares, useful in advanced layout calculations.

- Topic: Mathematics
- Type: function
- Browser support: Chrome 120+, Chrome Android 120+, Edge 120+, Firefox 118+, Firefox Android 118+, Safari 15.4+, Safari iOS 15.4+

## Example

Wrong:

```css
.line {
  width: sqrt(pow(var(--dx), 2) + pow(var(--dy), 2));
}
```

Right:

```css
.line {
  width: hypot(var(--dx), var(--dy));
}
```

`pow()` and `sqrt()` only accept numbers, while `hypot()` accepts lengths and returns a length.

## Common mistakes

- Mixing numbers and lengths like `hypot(3, 4px)`, which is invalid.

## Key points

- All arguments have the same type, like all lengths or all numbers.
- Distance is computed with `hypot()`, not `sqrt()` combined with `pow()` on lengths.
- A fallback value comes first where `hypot()` is unsupported.

## Interview questions

### What does hypot() return in CSS?

It returns a value of the same type as the arguments, so `hypot(30px, 40px)` is '50px'.

### Can hypot() take more than two arguments?

Yes. It accepts any number of arguments, so it also works for three-dimensional distances.

## Related cards

- [sqrt()](https://wonderium.dev/css/sqrt.md)
- [pow()](https://wonderium.dev/css/pow.md)
- [atan2()](https://wonderium.dev/css/atan2.md)
- [calc()](https://wonderium.dev/css/calc.md)
- [Math.hypot()](https://wonderium.dev/js/math-hypot.md)

---

- Level: [CSS](https://wonderium.dev/css.md)
- HTML version: https://wonderium.dev/css/hypot
- Last updated: 2026-11-25
