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.
.panel { transition: transform 300ms ease-out; animation: fade-in 0.5s 100ms both; }
Try it
The blue and orange dots move together because 2s and 2000ms are the same value.
Syntax
<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
0must be written as0sor0msin time properties; a bare0is 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.
.5sis allowed, but0.5sis clearer.500msavoids 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
transitionshorthand the first time is the duration and the second is the delay. - Performance. Duration does not make an animation cheaper: animate
transformandopacityrather than layout properties.
Browser support
Supported in every browser.
Related
transitionandanimationtransition-durationandanimation-delaydeg,rad,turnโ angle units- Lesson: CSS Transitions