<time> 5p1k2c
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. 4j5s8
Several properties in CSS accept time values, like transition-delay
, among others.
Notes and Trivia 4a537
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 u704t
- s
- Seconds.
- ms
- Milliseconds. There are 1000 milliseconds in a second.
Notes 441w3q
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 2h2053
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 572e63
Time units are ed in Chrome 11+, Firefox 4+, IE 9+, Opera 10.5+ and Safari 3.2+.
Notes 441w3q
Time units are not ed in Opera Mobile.