docs.rodeo

MDN Web Docs mirror

CSS data types

CSS data types define typical values (including keywords and units) accepted by CSS properties and functions. They are a special kind of component value type.

The most commonly-used types are defined in the CSS Values and Units module. This module also defines functional notations, which allow for more complex types or processing. Other types are defined in the specifications to which they apply.

Below you will find a reference to the types that you are most likely to come across, however it is not a comprehensive reference for all types defined in every CSS specification.

Syntax

In formal CSS syntax, data types are denoted by a keyword placed between the angle brackets < and >. They don’t correspond to any tangible CSS code entity.

Textual data types

These types include keywords and identifiers as well as strings, and URLs.

Numeric data types

These data types are used to indicate quantities, indexes, and positions. The majority of these are defined in the Values and Units specification, however additional types are described in other specifications where they are specific to that specification alone — for example the fr unit in CSS grid layout.

Quantities

These types are used to specify distance and other quantities.

Combinations of types

Some CSS properties can take a dimension or a percentage value. In this case the percentage value will be resolved to a quantity that matches the allowable dimension. Properties which can accept a percentage in addition to a dimension will use one of the types listed below.

Color

The CSS Color Specification defines the {{cssxref("&lt;color&gt;")}}  data type, and other types which relate to color in CSS.

Images

The CSS Images Specification defines the data types which deal with images, including gradients.

2D positioning

The {{cssxref("&lt;position&gt;")}}  data type is interpreted as defined for the {{cssxref("&lt;background-position&gt;")}}  property.

Calculation data types

These data types are used in CSS math function calculations.

Specifications

{{Specifications}} 

See also

In this article

View on MDN