CSS Portal

CSS <frequency> Data Type

If this site has been useful, we’d love your support! Consider buying us a coffee to keep things going strong!

Description

The <frequency> CSS data type represents a periodic rate, typically used to specify how often a wave, oscillation, or other cyclical effect occurs over time. It is most commonly applied in properties that deal with animations, transitions, or audio-related effects. Frequencies are measured in hertz (Hz), where one hertz corresponds to one cycle per second, allowing developers to control the speed of repetitive phenomena with precise numerical values. For example, you could define the oscillation of a CSS animation or the vibrational rate in a sound-based effect using this data type.

A <frequency> value can also use decimal numbers to allow for fractional cycles per second, giving finer control over timing. Negative values are not valid for <frequency>, since a frequency inherently represents a forward-moving cycle. This type is often combined with time-based CSS properties such as animation-duration or transition-duration to create rhythmic or oscillating visual effects.

For example, using <frequency> in a CSS animation could look like this:

@keyframes pulse {
  0% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.2);
  }
  100% {
    transform: scale(1);
  }
}

.box {
  animation-name: pulse;
  animation-duration: 2s;
  animation-iteration-count: infinite;
  /* frequency of oscillation: 0.5 Hz means 1 full pulse every 2 seconds */
  animation-timing-function: steps(1, end);
}

Another context where <frequency> is used is the hue-rotate() effect in conjunction with time-based transitions to create continuous color cycling:

.colorful {
  animation: spinColor 4s linear infinite;
}

@keyframes spinColor {
  0% {
    filter: hue-rotate(0deg);
  }
  100% {
    filter: hue-rotate(360deg);
  }
}

Here, while the filter itself does not directly take a frequency, the number of cycles completed per second is effectively controlled by the duration, linking time and frequency conceptually. The <frequency> data type provides a precise way to describe periodicity, making it a crucial tool for rhythmic and audio-visual effects in CSS.

Syntax

property: <frequency>;

Values

  • HzFrequency in hertz, represents the number of cycles per second.
  • kHzFrequency in kilohertz, represents the number of thousands of cycles per second (in other words, 1kHz equals 1000Hz).

Example

<div class="demo">
<h1>CSS &lt;frequency&gt; example</h1>
<ul class="notes">
<li class="note a">A4</li>
<li class="note a-octave">A5</li>
<li class="note custom">Custom (1kHz)</li>
</ul>
</div>
@property --tone-frequency {
  syntax: '';
  inherits: true;
  initial-value: 440Hz;
}

:root {
  --card-bg: #0f172a;
  --accent: #7c3aed;
  --muted: #cbd5e1;
}

body {
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial;
  background: linear-gradient(180deg, #071023 0%, #021025 100%);
  color: var(--muted);
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 2rem;
}

.demo {
  width: 100%;
  max-width: 640px;
  background: linear-gradient(180deg, rgba(255,255,255,0.02), rgba(255,255,255,0.01));
  border: 1px solid rgba(255,255,255,0.04);
  padding: 1.25rem 1.5rem;
  border-radius: 12px;
  box-shadow: 0 8px 30px rgba(2,6,23,0.6);
}

h1 {
  font-size: 1.1rem;
  margin: 0 0 0.75rem 0;
  color: #e6eef8;
}

.notes {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  gap: 0.75rem;
}

.note {
  flex: 1 1 0;
  padding: 1rem;
  border-radius: 8px;
  background: linear-gradient(180deg, rgba(255,255,255,0.03), rgba(255,255,255,0.01));
  text-align: center;
  font-weight: 600;
  color: #eaf2ff;
  position: relative;
}

.note::after {
  content: var(--tone-frequency);
  display: block;
  margin-top: 0.5rem;
  font-size: 0.85rem;
  color: rgba(234,242,255,0.9);
  opacity: 0.95;
}

.note.a { --tone-frequency: 440Hz; border: 1px solid rgba(124,58,237,0.15); }
.note.a-octave { --tone-frequency: 880Hz; border: 1px solid rgba(34,197,94,0.12); }
.note.custom { --tone-frequency: 1kHz; border: 1px solid rgba(14,165,233,0.12); }

/* Example values: 440Hz, 880Hz, 1kHz */

Browser Support

The following information will show you the current browser support for the CSS frequency data type. Hover over a browser icon to see the version that first introduced support for this CSS data type.

This data type is not supported by modern browsers.
Desktop
Chrome
Edge
Firefox
Opera
Safari
Tablets & Mobile
Chrome Android
Firefox Android
Opera Android
Safari iOS
Samsung Internet
Android WebView
-

Last updated by CSSPortal on: 2nd January 2026

If this site has been useful, we’d love your support! Consider buying us a coffee to keep things going strong!