round(), mod(), and rem()Baseline · Newly available
The round(), mod(), and rem() CSS functions compute rounded values and the remainder after division.
Works in the latest version of every major browser, but older devices may not support it yet. Baseline since May 17, 2024.
Browser support
DesktopChrome
1–124Not supported
125+Supportedsince May 14, 2024
Current: 155Edge
12–124Not supported
125+Supportedsince May 17, 2024
Current: 154Firefox
1–117Not supported
118+Supportedsince Sep 26, 2023
Current: 157Safari
1–17.1Not supported
17.2+Supportedsince Dec 11, 2023
Current: 27MobileChrome Android
18–124Not supported
125+Supportedsince May 14, 2024
Current: 155Firefox Android
4–117Not supported
118+Supportedsince Sep 26, 2023
Current: 157Safari iOS
1–17.1Not supported
17.2+Supportedsince Dec 11, 2023
Current: 27How to use
Every current browser supports this, but it only became Baseline on May 17, 2024. Use it as a progressive enhancement, or keep a fallback if you support older devices.
Example
Full syntax and examples are on MDN: mod.
Feature detection
CSS · check before using
@supports (width: mod(5px, 2px)) {
/* styles that use mod */
}
/* or in JavaScript */
if (CSS.supports("width", "mod(5px, 2px)")) {
// use it
}Specification
Sub-features
Support for each part of the feature (6). The overall table above shows when the whole feature works.
| Sub-feature | Chrome | Edge | Firefox | Safari | Chrome Android | Firefox Android | Safari iOS |
|---|---|---|---|---|---|---|---|
| <mod> | 125 | 125 | 118 | 15.4 | 125 | 118 | 15.4 |
| <mod>.mixed_type_parameters | 125 | 125 | 118 | 17.2 | 125 | 118 | 17.2 |
| <rem> | 125 | 125 | 118 | 15.4 | 125 | 118 | 15.4 |
| <rem>.mixed_type_parameters | 125 | 125 | 118 | 17.2 | 125 | 118 | 17.2 |
| <round> | 125 | 125 | 118 | 15.4 | 125 | 118 | 15.4 |
| <round>.mixed_type_parameters | 125 | 125 | 118 | 17.2 | 125 | 118 | 17.2 |