Skip to content
Tutorials Center
My learning

Topics

CSS Reference ยท Units and Values

The s and ms time units

Reference for the CSS time units s and ms: how seconds and milliseconds convert, which properties accept them, negative delays and reduced motion.

CSS has two time units: s for seconds and ms for milliseconds. 1s is exactly 1000ms, so 0.25s and 250ms are the same duration. A <time> value is a number immediately followed by the unit, with no space: 2s, 300ms, 0.5s.

Time values appear in transitions and animations (transition-duration, transition-delay, animation-duration, animation-delay), and the transition and animation shorthands.

CSS
.panel {
  transition: transform 300ms ease-out;
  animation: fade-in 0.5s 100ms both;
}

Try it

1s equals 1000ms

The blue and orange dots move together because 2s and 2000ms are the same value.

Syntax

CSS
<time> = <number>s | <number>ms
  • Applies to: any property that accepts a <time>.
  • Computed value: converted to seconds.
  • Animatable: time values are not usually animated, but the timing properties themselves are discrete.

Values

Unit Description Example
s Seconds. 1.5s
ms Milliseconds. 1000ms = 1s. 250ms

Usage notes

  • A unit is required. Even 0 must be written as 0s or 0ms in time properties; a bare 0 is invalid there.
  • Negative values. Delays may be negative: the animation then starts part-way through, as if it began earlier. Negative durations are invalid.
  • Decimals. .5s is allowed, but 0.5s is clearer. 500ms avoids decimals altogether.
  • Typical durations. Micro-interactions such as hover feedback feel good at 100ms to 200ms; larger movements at 250ms to 400ms. Long animations feel slow unless they are decorative.
  • Reduced motion. Respect @media (prefers-reduced-motion: reduce) by shortening or removing non-essential animation.
  • Multiple values. In a transition shorthand the first time is the duration and the second is the delay.
  • Performance. Duration does not make an animation cheaper: animate transform and opacity rather than layout properties.

Browser support

Supported in every browser.