coderef

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: 155
Edge
12–124Not supported
125+Supportedsince May 17, 2024
Current: 154
Firefox
1–117Not supported
118+Supportedsince Sep 26, 2023
Current: 157
Safari
1–17.1Not supported
17.2+Supportedsince Dec 11, 2023
Current: 27
MobileChrome Android
18–124Not supported
125+Supportedsince May 14, 2024
Current: 155
Firefox Android
4–117Not supported
118+Supportedsince Sep 26, 2023
Current: 157
Safari iOS
1–17.1Not supported
17.2+Supportedsince Dec 11, 2023
Current: 27

How 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
}

Sub-features

Support for each part of the feature (6). The overall table above shows when the whole feature works.

Sub-featureChromeEdgeFirefoxSafariChrome AndroidFirefox AndroidSafari iOS
<mod>12512511815.412511815.4
<mod>.mixed_type_parameters12512511817.212511817.2
<rem>12512511815.412511815.4
<rem>.mixed_type_parameters12512511817.212511817.2
<round>12512511815.412511815.4
<round>.mixed_type_parameters12512511817.212511817.2