CSS Reference Data Type

<time>

The <time> CSS data type represents a time dimension. The format of a time value is a <number> followed by a case-insensitive unit of time: seconds or milliseconds. There are no spaces allowed between the number and the unit.

Several properties in CSS accept time values, like transition-duration and transition-delay, among others.

Notes and Trivia

CSS <length> values allow removing the unit identifier from a value when that value is zero. When a <time> value is zero, on the other hand, the unit can not be omitted, as 0 alone won’t be a valid <time> value without its unit.

Values

s
Seconds.
ms
Milliseconds. There are 1000 milliseconds in a second.

Notes

Properties may restrict the time value to some range. If the value is outside the allowed range, the declaration is invalid and must be ignored. Negative values are allowed for some properties such as the transition-delay property.

Examples

The following example shows the use of a time value to specify the duration of a transition on an element, that applies a transition on the width of the element.

.el {
    transition-duration: 3s;
}
                

The following are all valid time values:

34.6s /* accepts non-integer values */
98MS /* unit is case-insensitive so it can be all-uppercase, although uppercase letters are not recommended for time values */
                

The following are invalid time values:

0 /* must have a unit */
56 /* must have a unit */
74 ms /* cannot have white space between number and unit */

Browser Support

Time units are supported in Chrome 11+, Firefox 4+, IE 9+, Opera 10.5+ and Safari 3.2+.

Notes

Time units are not supported in Opera Mobile.

Written by . Last updated February 4, 2015 at 4:59 pm by Manoela Ilic.

Do you have a suggestion, question or want to contribute? Submit an issue.