Get to know MDN better
Since May 2024, this feature works across the latest devices and browser versions. This feature might not work in older devices or browsers.
The rem() CSS function returns a remainder left over when the first parameter is divided by the second parameter, similar to the JavaScript remainder operator (%). The remainder is the value left over when one operand, the dividend, is divided by a second operand, the divisor. It always takes the sign of the dividend.
Note: To read about the unit rem, see the <length> page.
For example, the CSS rem(27, 5) function returns the remainder of 2. When dividing 27 by 5, the result is 5 with a remainder of 2. The full calculation is 27 / 5 = 5 * 5 + 2.
The rem(dividend, divisor) function accepts two comma-separated values as its parameters. Both parameters must have the same type, number, dimension, or <percentage>, for the function to be valid. While the units in the two parameters don't need to be the same, they do need of the same dimension type, such as <length>, <angle>, <time>, or <frequency> to be valid.
dividendA calculation that resolves to a <number>, <dimension>, or <percentage> representing the dividend.
divisorA calculation that resolves to a <number>, <dimension>, or <percentage> representing the divisor.
Returns a <number>, <dimension>, or <percentage> (corresponds to the parameters' type) representing the remainder, that is, the operation left over.
| CSS Values and Units Module Level 4 # funcdef-rem |
Enable JavaScript to view this browser compatibility table.
This page was last modified on Apr 18, 2026 by MDN contributors.
Your blueprint for a better internet.
Portions of this content are ©1998–2026 by individual mozilla.org contributors. Content available under a Creative Commons license.