<integer>

The <integer> CSS data type is a type of <number> that represents a whole number, whether positive or negative. Integers are used in numerous CSS properties, such as z-index, counter-increment, column-count, grid-column, grid-row, and repeat().

Syntax

An integer consists of one or several decimal digits, 0 through 9 inclusive, optionally preceded by a single "+" or "-" sign. There is no unit associated with integers.

There is no official range of valid <integer> values. Opera supports values up to 215-1, IE up to 220-1, and other browsers even higher. During the CSS3 Values cycle there was a lot of discussion about setting a minimal limit to support: the latest decision, in April 2012 during the LC phase, was [-227-1; 227-1] #, but other values like 224-1 and 230-1 were also proposed # #. The latest Editor's draft doesn't list a limit anymore.

Interpolation

Values of the <integer> CSS data type can be interpolated in animations. They are interpolated using discrete, whole steps. The calculation is done as if they were real, floating-point numbers; the discrete value is obtained using the floor function. The speed of the interpolation is determined by the timing function associated with the animation.

Examples

Valid integer values

12          Positive integer (without a leading + sign)
+123        Positive integer (with a leading + sign)
-456        Negative integer
0           Zero
+0          Zero, with a leading +
-0          Zero, with a leading -

Invalid integer values

12.0        This is a <number>, not an <integer>, though it represents an integer.
12.         Decimal points are not allowed.
+---12      Only one leading +/- is allowed.
ten         Letters are not allowed.
_5          Special characters are not allowed.
\35         Escaped Unicode characters are not allowed, even if they are an integer (here: 5).
\4E94       Non-arabic numerals are not allowed, even when escaped (here: the Japanese 5, 五).
3e4         Scientific notation is not allowed.

Specifications

Specification Status Comment
CSS Values and Units Module Level 3
The definition of '<integer>' in that specification.
Candidate Recommendation No significant change.
CSS Level 2 (Revision 1)
The definition of '<integer>' in that specification.
Recommendation Explicit definition.
CSS Level 1
The definition of '<integer>' in that specification.
Recommendation Implicit definition.

Browser compatibility

Feature Chrome Firefox (Gecko) Internet Explorer Opera Safari (WebKit)
basic 1.0 1.0 (1.0) 3.0 yes 1.0 (85)
Feature Android Firefox Mobile (Gecko) IE Phone Opera Mobile Safari Mobile
Basic support yes yes yes yes yes

Document Tags and Contributors

 Last updated by: mfluehr,