exp()
Example
.box {
width: exp(2rem);
}.box {
width: calc(exp(2) * 1rem);
}exp() only takes numbers and returns a number, so it is multiplied by '1rem' to produce a width.
Common mistakes
- Passing a length like
exp(2px), which is invalid.
Key points
- The argument is a plain number, not a length or percentage.
- The number result is multiplied by a unit inside
calc()when a length is needed. pow()is used instead when the base is note.
Interview questions
What is the difference between exp() and pow() in CSS?
exp(x) always raises e to the power x. pow() takes any base, like pow(2, 3).
Is there an e constant in CSS?
Yes. CSS math functions accept the e keyword, so calc(e * 1px) is valid.