`acos()` CSS function
Baseline Widely available
This feature is well established and works across many devices and browser versions. It's been available across browsers since March 2023.
The acos() CSS function is a trigonometric function that returns the inverse cosine of a number between -1 and 1. The function contains a single calculation that returns an <angle> between 0deg and 180deg.
Syntax
/* Single <number> values */ transform: rotate(acos(-0.2)); transform: rotate(acos(2 * 0.125)); /* Other values */ transform: rotate(acos(pi / 5)); transform: rotate(acos(e / 3));
Parameters
The acos(number) function accepts only one value as its parameter.
-
number - A calculation which resolves to a
<number>between-1and1.
Return value
The inverse cosine of a number will always return an <angle> between 0deg and 180deg.
- If
numberis less than-1or greater than1, the result isNaN. - If
numberis exactly1, the result is0.
Formal syntax
<acos()> = acos( <calc-sum> ) <calc-sum> = <calc-product> [ [ '+' | '-' ] <calc-product> ]* <calc-product> = <calc-value> [ '*' <calc-value> | '/' <number> ]* <calc-value> = <number> | <dimension> | <percentage> | <calc-constant> | ( <calc-sum> ) <calc-constant> = e | pi | infinity | -infinity | NaN
Examples
Rotate elements
The acos() function can be used to rotate elements as it returns an <angle>.
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
body {
height: 100vh;
display: flex;
justify-content: center;
align-items: center;
gap: 50px;
}
div.box {
width: 100px;
height: 100px;
background: linear-gradient(orange, red);
}
div.box-1 {
transform: rotate(acos(1));
}
div.box-2 {
transform: rotate(acos(0.5));
}
div.box-3 {
transform: rotate(acos(0));
}
div.box-4 {
transform: rotate(acos(-0.5));
}
div.box-5 {
transform: rotate(acos(-1));
}
Result
Specifications
| Specification |
|---|
| CSS Values and Units Module Level 4 # trig-funcs |
Browser compatibility
| Desktop | Mobile | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Chrome | Edge | Firefox | Opera | Safari | Chrome Android | Firefox for Android | Opera Android | Safari on iOS | Samsung Internet | WebView Android | WebView on iOS | |
acos |
111 |
111 |
108 |
97 |
15.4 |
111 |
108 |
75 |
15.4 |
22.0 |
111 |
15.4 |
See also
© 2005–2025 MDN contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-US/docs/Web/CSS/Reference/Values/acos