CSS atan2() function

Definition and usage

CSS atan2() The function returns the arctangent of two values between -∞ to ∞.

These values can be numbers, sizes, or percentages. Both values must be of the same type.

This function returns an angle between -180 to 180 degrees.

Example

Using atan2() Rotated element:

div.a {
  transform: rotate(atan2(50, 100));
}
div.b {
  transform: rotate(atan2(30px, -3rem));
}
div.c {
  transform: rotate(atan2(40%, 75%));
}
div.d {
  transform: rotate(atan2(pi, 25));
}

Try it yourself

CSS syntax

atan2(y, x)
Value Description
y Required. The y coordinate. It can be a number, size, or percentage.
x Required. The x coordinate. It can be a number, size, or percentage.

Technical details

Version: CSS4

Browser support

The numbers in the table represent the first browser version that fully supports this function.

Chrome Edge Firefox Safari Opera
111 111 108 15.4 97

Related pages

Reference:CSS acos() function

Reference:CSS asin() function

Reference:CSS atan() function

Reference:CSS calc() function

Reference:CSS cos() function

Reference:CSS exp() function

Reference:CSS hypot() function

Reference:CSS log() function

Reference:CSS mod() function

Reference:CSS pow() function

Reference:CSS sin() function

Reference:CSS sqrt() function

Reference:CSS tan() function