Knowledge baseExam Center
ENEnglish
Choose language13

CKTIS / CSS

s — the CSS second

The `s` unit represents seconds in CSS `<time>` values. A value of `0.5s` equals `500ms`. It can be used, for example, to specify transition durations and delays.

Version: CSS modules; structured CSSWG indexes reconciled with pinned MDN BCD; Chromium 152 scope gate, per-example verification still required

Syntax

<number>s

s is the time unit for seconds. Write the number immediately before the unit, without a space: 0.5s, not 0.5 s. The units s and ms are convertible: 1s equals 1000ms. The canonical unit of <time> is s.

In transition-duration, 0.5s sets a half-second transition duration, while transition-delay: 0s means no delay. Setting a duration alone does not start a transition: a suitable property-value change is also needed. The example configures an opacity transition but does not trigger such a change.

Restrictions depend on the property: transition-duration does not allow negative time, whereas transition-delay can be negative — the transition then starts as though part of its time has already elapsed. In these declarations, write zero as 0s or 0ms, not as unitless 0.

Examples

<!doctype html>
<html lang="en">
<head>
  <meta charset="utf-8">
  <title>s — CSS seconds</title>
  <style>
    .sample {
      transition-property: opacity;
      transition-duration: 0.5s;
      transition-delay: 0s;
    }
  </style>
</head>
<body>
  <p class="sample">Opacity transition sample</p>
  <script>
    const style = getComputedStyle(document.querySelector('.sample'));
    console.log(`transition-property: ${style.transitionProperty}`);
    console.log(`transition-duration: ${style.transitionDuration}`);
    console.log(`transition-delay: ${style.transitionDelay}`);
  </script>
</body>
</html>

Result

transition-property: opacity
transition-duration: 0.5s
transition-delay: 0s

The displayed code and declared result were verified in an isolated environment using the method recorded in the verification evidence for this exact version.

Sources