Favorites

CSS <number> Data Type

<number>
CSS Data TypeThis data type is supported by all modern browsers.
Updated 21st November 2026

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.

Looks like you're using an ad blocker, and that's fine! Ads help keep CSS Portal's generators and references free, so if the site's useful to you, visit our Support page to see other ways to help.

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.

Demo Code
HTML Code
<p class="demo-element">Typography is the art of arranging type. Good spacing, line length and alignment make text easy to read.</p>
CSS Code
.demo-element {
	width: 260px;
	margin: 0;
	padding: 10px 12px;
	border: 2px solid #4361ee;
	border-radius: 6px;
	background: #e7ecff;
	color: #1b1f3b;
	font-size: 16px;
	line-height: 1;
}

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

<div class='example' role='group' aria-label='Progress example'>
<div class='meter' aria-hidden='true'>
<div class='fill'></div>
</div>
<p class='label'>Progress animation using CSS &lt;number&gt; custom property</p>
</div>
/* Register a numeric custom property so it can be animated */
@property --progress {
  syntax: '';
  inherits: false;
  initial-value: 0;
}

/* Container */
.example {
  --progress: 0;
  width: 360px;
  margin: 28px auto;
  font-family: system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Arial;
  animation: increase 4s ease-in-out forwards;
}

/* Visual meter */
.meter {
  width: 100%;
  height: 18px;
  background: #e9e9e9;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.6);
}
.fill {
  /* Use the numeric custom property directly in a calc; it represents a plain number */
  width: calc(var(--progress) * 1%);
  height: 100%;
  background: linear-gradient(90deg, #4caf50, #8bc34a);
  transition: width 300ms linear;
}

.label {
  margin-top: 10px;
  font-size: 13px;
  color: #333;
  text-align: center;
}

/* Animate the numeric custom property (possible because of @property syntax '') */
@keyframes increase {
  0%   { --progress: 8; }
  50%  { --progress: 64; }
  100% { --progress: 100; }
}
Open in editor

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.

This data type is supported by all modern browsers.

Desktop

Chrome
Edge
Firefox
Opera
Safari

Tablets & Mobile

Chrome Android
Firefox Android
Opera Android
Safari iOS
Samsung Internet
Android WebView
-
Supported Unknown Not supported

Looks like you're using an ad blocker, and that's fine! Ads help keep CSS Portal's generators and references free, so if the site's useful to you, visit our Support page to see other ways to help.