Favorites

acos() CSS Function

acos()
CSS FunctionThis function is supported by all modern browsers.
Updated 21st November 2026

The acos() function returns the arccosine of a number between -1 and 1, as an angle.

☕
Enjoying this site?

Help keep it running with a small coffee donation. Every bit of support is appreciated!

Buy us a coffee

Description

The acos() CSS function calculates the arccosine (inverse cosine) of a number. It returns the angle whose cosine is the given value. The argument is a <number> between -1 and 1, and the result is an <angle> between 0deg and 180deg. For example, acos(1) is 0deg, acos(0) is 90deg and acos(-1) is 180deg. Values outside -1 to 1 return NaN.

Because acos() maps the range -1 to 1 onto a half circle, it is useful for semicircular gauges and meters: a value of 1 points one way, -1 points the opposite way, and everything in between is spread across the arc.

The acos() 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.

/* acos(0.5) = 60deg */
.hand {
  rotate: acos(0.5);
}

/* A half-circle gauge driven by a value from -1 to 1 */
.meter .needle {
  rotate: calc(acos(var(--value)) * -1);
}

Interactive Demo

Demo Code
HTML Code
<div class="demo-dial">
	<div class="demo-element"></div>
</div>
CSS Code
.demo-dial {
	position: relative;
	width: 200px;
	height: 200px;
	border-radius: 50%;
	background: repeating-conic-gradient(from 90deg, #b0b0b0 0 1deg, transparent 1deg 15deg), #f4f4f4;
	outline: 1px solid #c5c5c5;
}
.demo-dial::after {
	content: "";
	position: absolute;
	left: 100px;
	top: 100px;
	width: 100px;
	border-top: 1px dashed #4361ee;
}
.demo-element {
	position: absolute;
	left: 100px;
	top: 98px;
	width: 95px;
	height: 4px;
	border-radius: 2px;
	background: #f72585;
	transform-origin: 0 50%;
	rotate: acos(1);
}

Syntax

acos() = acos( <calc-sum> )

Values

  • <calc-sum>A calculation resolving to a <number> between -1 and 1. The function returns an <angle> between 0deg and 180deg.

Example

<div class="wrap">
<h1>CSS acos() examples</h1>
<div class="grid">
<div class="card">
<div class="dial"><span class="needle" style="--v: 1"></span></div>
<div class="label">acos(1) = 0deg</div>
</div>
<div class="card">
<div class="dial"><span class="needle" style="--v: 0.5"></span></div>
<div class="label">acos(0.5) = 60deg</div>
</div>
<div class="card">
<div class="dial"><span class="needle" style="--v: 0"></span></div>
<div class="label">acos(0) = 90deg</div>
</div>
<div class="card">
<div class="dial"><span class="needle" style="--v: -1"></span></div>
<div class="label">acos(-1) = 180deg</div>
</div>
</div>
<p class="note">Needles are rotated counter-clockwise by the angle acos() returns.</p>
</div>
/* Base demo layout */
* { box-sizing: border-box; }

body {
margin: 24px;
font-family: system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Arial;
background: #f5f7fb;
color: #102a43;
}

.wrap {
max-width: 860px;
margin: 0 auto;
}

h1 {
font-size: 20px;
margin: 0 0 16px;
}

.grid {
display: grid;
grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
gap: 16px;
}

.card {
background: #fff;
border-radius: 12px;
padding: 16px;
box-shadow: 0 6px 18px rgba(16, 42, 67, 0.08);
}

.label {
font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, monospace;
font-size: 12px;
color: #486581;
margin-top: 10px;
word-break: break-word;
}

.note {
font-size: 13px;
color: #486581;
margin-top: 14px;
}

/* acos() examples */
.dial {
position: relative;
width: 120px;
height: 120px;
margin: 0 auto;
border-radius: 50%;
background: #e2e8f0;
}

.needle {
position: absolute;
left: 50%;
top: 50%;
width: 52px;
height: 4px;
margin-top: -2px;
border-radius: 2px;
background: #dc2626;
transform-origin: left center;
}

.dial::after {
content: '';
position: absolute;
left: 50%;
top: 50%;
width: 10px;
height: 10px;
margin: -5px 0 0 -5px;
border-radius: 50%;
background: #0f172a;
}

.needle { rotate: calc(acos(var(--v)) * -1); }
Open in editor

Browser Support

The following information will show you the current browser support for the CSS acos() function. Hover over a browser icon to see the version that first introduced support for this CSS function.

This function is supported by all modern browsers.

Desktop

Chrome
Edge
Firefox
Opera
Safari

Tablets & Mobile

Chrome Android
Firefox Android
Opera Android
Safari iOS
Samsung Internet
Android WebView
-
Supported Unknown Not supported
☕
Enjoying this site?

Help keep it running with a small coffee donation. Every bit of support is appreciated!

Buy us a coffee