Knowledge baseExam Center
ENEnglish
Choose language13

CKTIS / CSS

ms — millisecond

The `ms` unit represents time in CSS. One millisecond is one thousandth of a second: `250ms` and `0.25s` represent the same duration. Use it in properties that accept values of type `<time>`.

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

Syntax

<number>ms

ms is the millisecond unit of the <time> type. Write the number directly before the unit, without whitespace: 250ms, not 250 ms. The conversion is 1000ms = 1s; ms and s are compatible units, with s as the canonical unit. Include a unit even for zero: 0ms.

The permitted range depends on the property. transition-duration rejects negative values, whereas transition-delay permits them. A negative delay starts the transition at the point corresponding to time that has already elapsed; it does not mean a negative duration.

The example sets an opacity transition duration of 250ms, with no delay. Declaring these properties alone does not change opacity: a transition requires its value to change. The expected computed values are 0.25s and 0s, because computed time values are serialized in seconds.

Examples

<!doctype html>
<html lang="en">
<head>
  <meta charset="utf-8">
  <title>CSS transition times in milliseconds</title>
  <style>
    .sample {
      transition-property: opacity;
      transition-duration: 250ms;
      transition-delay: 0ms;
    }
  </style>
</head>
<body>
  <p class="sample">This element has a 250 ms opacity transition with no delay.</p>
  <script>
    const style = getComputedStyle(document.querySelector('.sample'));
    console.log(`transition-duration: ${style.transitionDuration}`);
    console.log(`transition-delay: ${style.transitionDelay}`);
  </script>
</body>
</html>

Result

transition-duration: 0.25s
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