« CSS « CSS Reference
Summary
The <number> CSS data type represents a number, either integer or fractional. Its syntax extends the one of the <integer> data value. To represent a fractional value, add the fractional part — a '.' followed by one or several decimal digits — to any <integer> data value. Like for <integer> data type, there isn't any unit associated to a <number>, which is not a CSS dimension.
Interpolation
Values of the <number> CSS data type can be interpolated in order to allow animations. In that case they are interpolated as real, floating-point, numbers. The speed of the interpolation is determined by the timing function associated with the animation.
Examples
These are valid number values:
12 A raw <integer> is also a <number> 4.01 A positive non-integer <number> -456.8 Negative non-integer <number> 0.0 Zero +0.0 Zero, with a leading + -0.0 Zero, with a leading - (Though strange, this is an allowed value) .60 Digits are optional before the dot
These are invalid number values:
12. The dot should be followed by a number +---12.2 Only one leading +/- is allowed 12.1.1 Only one dot is allowed 10e3 The e notation is not allowed
Specifications
| Specification | Status | Comment |
|---|---|---|
| CSS Values and Units Module Level 3 | Working Draft | No significant change from CSS Level 2 (Revision 1) |
| CSS Level 2 (Revision 1) | Recommendation | Explicitly defined |
| CSS Level 1 | Recommendation | Implicitly defined |
Browser Compatibility
| Feature | Chrome | Firefox (Gecko) | Internet Explorer | Opera | Safari (WebKit) |
|---|---|---|---|---|---|
| basic | 1.0 | 1.0 (1.0) | <=5.0 | yes | 1.0 (85) |
| Feature | Android | Firefox Mobile (Gecko) | IE Phone | Opera Mobile | Safari Mobile |
|---|---|---|---|---|---|
| Basic support | yes | yes | yes | yes | yes |
See also
- CSS Reference index
- CSS Data Types :
<angle>,<color>,<frequency>,<gradient>,<image>,<length>,<number>,<percentage>,<position>,<ratio>,<resolution>,<shape>,<string>,<time>,<timing-function>,<uri>,<user-ident>


Mozilla Developer Network