Favorites

sin() CSS Function

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

The sin() function returns the sine of an angle, a number between -1 and 1, useful for circular layouts and wave effects.

☕
Enjoying this site?

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

Buy us a coffee

Description

The sin() CSS function calculates the sine of an angle. The argument is an <angle>, such as 30deg or 0.25turn, or a plain number, which is treated as radians. The result is a <number> between -1 and 1. For example, sin(30deg) is 0.5 and sin(90deg) is 1.

In layout, sine gives the vertical position of a point on a circle, and it produces smooth wave patterns. Multiply the result by a length to turn it into a distance: calc(sin(45deg) * 100px) is about 70.7px. Together with cos(), it lets you place items around a circle or along a curve purely in CSS.

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

/* Place dots on a sine wave using an index */
.dot {
  translate: 0 calc(sin(var(--i) * 30deg) * 40px);
}

/* Vertical position on a circle of radius 100px */
.item {
  top: calc(50% + sin(var(--angle)) * 100px);
}

Interactive Demo

050px100px150px200px250px
Demo Code
HTML Code
<div class="demo-track">
	<div class="demo-element"></div>
</div>
<div class="demo-scale"><span>0</span><span>50px</span><span>100px</span><span>150px</span><span>200px</span><span>250px</span></div>
CSS Code
.demo-track {
	width: 300px;
	height: 36px;
	background: #f4f4f4 repeating-linear-gradient(90deg, #b0b0b0 0 1px, transparent 1px 50px);
	outline: 1px solid #c5c5c5;
}
.demo-scale {
	display: grid;
	grid-template-columns: repeat(6, 50px);
	width: 300px;
	font-size: 11px;
	color: #666;
}
.demo-element {
	height: 100%;
	background: linear-gradient(90deg, #f72585, #b5179e);
	width: calc(sin(30deg) * 300px);
}

Syntax

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

Values

  • <calc-sum>A calculation resolving to an <angle> or a <number> (interpreted as radians). The function returns a <number> from -1 to 1.

Example

<div class="wrap">
<h1>CSS sin() examples</h1>
<div class="card wave">
<span class="dot" style="--i: 0"></span>
<span class="dot" style="--i: 1"></span>
<span class="dot" style="--i: 2"></span>
<span class="dot" style="--i: 3"></span>
<span class="dot" style="--i: 4"></span>
<span class="dot" style="--i: 5"></span>
<span class="dot" style="--i: 6"></span>
<span class="dot" style="--i: 7"></span>
<span class="dot" style="--i: 8"></span>
<span class="dot" style="--i: 9"></span>
<span class="dot" style="--i: 10"></span>
<span class="dot" style="--i: 11"></span>
<span class="dot" style="--i: 12"></span>
</div>
<p class="note">Each dot is moved by calc(sin(var(--i) * 30deg) * -50px).</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;
}

/* sin() examples */
.wave {
display: flex;
justify-content: space-between;
align-items: center;
height: 140px;
}

.dot {
width: 16px;
height: 16px;
border-radius: 50%;
background: #2563eb;
translate: 0 calc(sin(var(--i) * 30deg) * -50px);
}
Open in editor

Browser Support

The following information will show you the current browser support for the CSS sin() 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