Predefined mathematical values.
Summary of characteristics of the e value
e (the basis of natural logarithms), which is approximately 2.7182818284590452354.Predefined mathematical values in CSS.
These values can be used in an expression evaluated with the calc() function or another calculation function, but not directly as a property value.
For example, scale:pi; is incorrect, whereas scale:calc(pi); is correct.
It is also important to ensure type matching: width:calc(pi) is incorrect because the width property expects a dimension,
whereas pi is a unitless number. However, there is a trick to adapt the types. It consists of writing width:calc(pi * 1px);.
- e: logarithm base, approximately the value
2.7182818284590452354. pi: the value ofpiis approximately3.1415926535897932.
The following values result from an impossible calculation (for example, division by zero) or an attempt to calculate with a non-numeric value:
NaN(Not a Number):indicates that a calculation could not be performed because a value passed as an argument was not a number.
Note that, unlike usual CSS practice,NaNis case-sensitive.infinityand-infinity: these two values usually result from a division by zero. According to the specification, these two terms can also be used as a value to mean 'the largest possible value.'
These values can be used with:
These values can only be used as a parameter for the function calc() and a few other calculation functions. Care must also be taken to match the types:
- The type of the value must correspond to the data type expected by the property.
- If the value is included in a calculation, its type must also be consistent with the calculation.
CSS is quite strict about data types: for example, an integer numeric value like 200 is not interchangeable with the dimension 200px.
Syntax of mathematical calculation values.
- rotate: calc(pi / 4 * 1rad);
In this example, the value
pi / 4is used to set a rotation. It's surprising, but the valuepiis not of an angular type: it must therefore be multiplied by an angular value (in degrees, radians, etc.) to make it compatible with therotateproperty.Note: the
rotate:0.25turn;notation is equivalent. - scale: calc(e);
The value
ebeing a unitless number, it can be used to set a property likescale, which also expects a unitless number. - width: calc(infinity * 1px);
According to the specification, this notation means 'give the element the maximum possible width'.
Simulator.
This simulator is particularly useful for identifying the mathematical values recognized by your current browser.
The type of value returned by the function must match the data type expected by the property being used. For this reason, the predefined value
is multiplied by 1px to convert the value into a dimension, by 1rad or 1deg to convert it into an angle, etc.
Support for mathematical values by browsers.
The predefined values mentioned on this page are now well supported by major browsers (2025).
NaN error code (Not A Number) indicating a non-numeric value where a numeric value is expected.infinity and -infinity.e (base of natural logarithms), which is approximately 2.718282.pi used in logarithmic calculations. Its approximate value is 3.1416.NaNvalue
infinityvalue
evalue
pivalue
Browsers on computers :
Mobile browsers :
Outdated or marginal browsers :

Internet Explorer

Baidu Browser

QQ Browser

Opéra Mobile

Firefox

Chrome

Safari

Edge

Opéra

Chrome pour Androïd

Safari sur IOS

Samsung Internet

UC Browser pour Androïd

Androïd Brower

Firefox pour Androïd

KaiOS Browser

Opéra mini
History of these predefined values.
-
CSS Values and Units Module Level 4
Introduction of the mathematical constantseandpi, as well as the error codesNaNandinfinity.August 14, 2018Working Draft.
See also, regarding the calculations.
In addition to these predefined values, many mathematical calculation functions now exist in CSS, and their definitions are described in the module CSS Values and Units Module.
Properties:

Functions:


calc-size() allows calculations on the intrinsic dimension of an element (defined by the content).












