CSS <number> Data Type
The <number> data type is a number without a unit, whole or with decimals, such as 1.5, used for line-height, opacity, scale and flex-grow.
Description
The <number> CSS data type represents numeric values in CSS that are not associated with any specific units. Unlike the <length> type, which requires units such as px or em, a <number> is a plain number, which can be an integer or a decimal. It is commonly used in contexts where numeric scaling, weighting, or counts are required, rather than physical measurements.
A key feature of the <number> type is that it can accept both positive and negative values depending on the property it is applied to. For example, the opacity property accepts a <number> value between 0 and 1, while the flex-grow property uses non-negative numbers to determine how much a flex item should grow relative to the rest.
Other common uses of <number> include unitless line-height values, which multiply the font size, animation-iteration-count, and the arguments of functions such as scale(), brightness() and cubic-bezier(). Numbers are also essential in calc(), where multiplying or dividing by a number scales another value, for example calc(var(--gap) * 1.5). Properties such as z-index and order require whole numbers and use the related <integer> type instead.
Examples:
/* Flex item growth using numbers */
.item {
flex-grow: 2; /* plain number */
}
/* Opacity using a decimal number */
.overlay {
opacity: 0.75; /* number between 0 and 1 */
}
/* Unitless line-height: 1.6 times the font size */
p {
line-height: 1.6;
}
In summary, <number> is a versatile data type in CSS for purely numeric values, often used in proportional, scalar, or count-based properties where units are unnecessary. It contrasts with types like <length> or <percentage>, which attach meaning through units or context.
Interactive Demo
Typography is the art of arranging type. Good spacing, line length and alignment make text easy to read.
Syntax
property: <number>;
Values
- <number>A number can consist of the following: Digits 0 to 9, decimal point ( . ), addition ( + ), minus ( - ) or an exponent composed of "e" or "E" and an integer.
Example
Browser Support
The following information will show you the current browser support for the CSS number data type. Hover over a browser icon to see the version that first introduced support for this CSS data type.
Desktop





Tablets & Mobile





