atan()
Baseline 2023Newly available
Since March 2023, this feature works across the latest devices and browser versions. This feature might not work in older devices or browsers.
The atan()
CSS function is a trigonometric function that returns the inverse tangent of a number between -∞
and +∞
. The function contains a single calculation that returns the number of radians representing an <angle>
between -90deg
and 90deg
.
Syntax
css
/* Single <number> values */
transform: rotate(atan(1));
transform: rotate(atan(4 * 50));
/* Other values */
transform: rotate(atan(pi / 2));
transform: rotate(atan(e * 3));
Parameters
Return value
The inverse tangent of an number
will always return an <angle>
between -90deg
and 90deg
.
- If
number
is0⁻
, the result is0⁻
. - If
number
is+∞
the result is90deg
. - If
number
is-∞
the result is-90deg
.
That is:
atan(-infinity)
representing-90deg
.atan(-1)
representing-45deg
atan(0)
representing0deg
atan(1)
representing45deg
atan(infinity)
representing90deg
.
Formal syntax
Examples
Rotate elements
The atan()
function can be used to rotate
elements as it return an <angle>
.
HTML
html
<div class="box box-1"></div>
<div class="box box-2"></div>
<div class="box box-3"></div>
<div class="box box-4"></div>
<div class="box box-5"></div>
CSS
css
div.box {
width: 100px;
height: 100px;
background: linear-gradient(orange, red);
}
div.box-1 {
transform: rotate(atan(-99999));
}
div.box-2 {
transform: rotate(atan(-1));
}
div.box-3 {
transform: rotate(atan(0));
}
div.box-4 {
transform: rotate(atan(1));
}
div.box-5 {
transform: rotate(atan(99999));
}
Result
Specifications
Specification |
---|
CSS Values and Units Module Level 4 # trig-funcs |
Browser compatibility
Report problems with this compatibility data on GitHubdesktop | mobile | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
atan() |
Legend
Tip: you can click/tap on a cell for more information.
- Full support
- Full support
- No support
- No support
The compatibility table on this page is generated from structured data. If you'd like to contribute to the data, please check out https://github.com/mdn/browser-compat-data and send us a pull request.