atan() CSS Function
The atan() function returns the arctangent of a number, as an angle between -90deg and 90deg.
Description
The atan() CSS function calculates the arctangent (inverse tangent) of a number. It returns the angle whose tangent is the given value. The argument can be any <number>, from negative to positive infinity, and the result is an <angle> between -90deg and 90deg. For example, atan(1) is 45deg, and atan(infinity) is 90deg.
The tangent of an angle is a slope (rise over run), so atan() converts a slope back into an angle. This is useful for rotating an element so it lines up with a diagonal, when you know the ratio of height to width. If you have the two sides as separate lengths, atan2() is usually more convenient because it accepts both values and handles every direction.
The atan() function is one of the CSS trigonometric functions, together with sin(), cos(), tan(), asin(), acos(), atan() and atan2(). Like calc(), it can be used anywhere a value of the matching type is accepted, and its arguments can contain full calculations, custom properties and the constants pi and e.
/* Rotate to match a 1:1 slope (45deg) */
.diagonal {
rotate: atan(1);
}
/* Rotate to match the slope of a 16:9 box's diagonal */
.ribbon {
rotate: atan(9 / 16); /* about 29.4deg */
}
Interactive Demo
Syntax
atan() = atan( <calc-sum> )
Values
- <calc-sum>A calculation resolving to a <number>. The function returns an <angle> between -90deg and 90deg.
Example
Browser Support
The following information will show you the current browser support for the CSS atan() function. Hover over a browser icon to see the version that first introduced support for this CSS function.
Desktop





Tablets & Mobile





