The <time>
CSS data type denotes time dimensions expressed in seconds or milliseconds. They consists of a <number>
immediately followed by the unit. Like for any CSS dimension, there is no space between the unit literal and the number.
The following units may be used :
s
which represents a time in seconds. E.g. 0s
, 1.5s
, -60s
.ms
which represents a time in milliseconds. E.g. 0ms
, 1500ms
, -60000ms
.Conversion between s
and ms
follows the logical 1s
= 1000ms
.
Even if all units represent the same time for the value 0
, the unit may not be omitted in that case as it isn't a <length>
: 0
is invalid and does not represent 0s
, 0ms
.
These are valid time values:
12s Positive integer -456ms Negative integer 4.3ms Non-integer 14mS The unit is case-insensitive, though capital letters are not recommended for s and ms. +0s Zero, with a leading + and the unit -0ms Zero, with a leading - and the unit (Though strange, this is an allowed value)
These are invalid time values:
0 While unitless zero is allowed for <length>, it's invalid for all other units. 12.0 This is a <number>, not a <time>, it must have a unit 7 ms No space is allowed between the <number> and the unit
Specification | Status | Comment |
---|---|---|
CSS Values and Units Module Level 3 The definition of '<time>' in that specification. | Candidate Recommendation | Normatively defined s and ms
|
CSS Level 2 (Revision 1) The definition of '<time>' in that specification. | Recommendation | Informatively defined s and ms
|
Feature | Chrome | Firefox (Gecko) | Internet Explorer | Opera | Safari |
---|---|---|---|---|---|
Basic support | (Yes) | 4.0 (2.0) | 9.0 | 10.5 (2.3) | (Yes) |
Feature | Android | Firefox Mobile (Gecko) | IE Mobile | Opera Mobile | Safari Mobile |
---|---|---|---|---|---|
Basic support | ? | ? | ? | No support | ? |
© 2005–2017 Mozilla Developer Network and individual contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-US/docs/Web/CSS/time