math.div($number1, $number2) divides the first number by the second. Shared units cancel. Units only in the first stay in the numerator; units only in the second move to the denominator. Prefer it over slash / division. Load it with @use "sass:math" on Dart Sass 1.33+.
Slash is ambiguous in Sass (division vs CSS separators such as font: 16px/1.5). Slash division is deprecated. Use math.div for math, and list.slash when you need a slash-separated list.
Legacy string behavior.
Official docs: for compatibility, math.div still mirrors some deprecated / behaviors (including string concatenation). Do not rely on that in new stylesheets.
Syntax
Syntax
SCSS
@use "sass:math";
math.div($number1, $number2); //=> number
math.div(1, 2); // 0.5
math.div(100px, 5px); // 20 (px cancels)
math.div(100px, 5); // 20px
math.div(100px, 5s); // complex unit (often calc() today)
// Prefer math.div over deprecated slash division:
// $x: 100px / 5px; // avoid
// Module API — prefer math.div after @use "sass:math"
Pattern: divide two Sass numbers → let shared units cancel → use the unitless result as a ratio, or keep leftover units as a CSS length/rate.
Reference
Units After Division
How units move through math.div:
Call
Result
math.div(1, 2)
0.5 (unitless)
math.div(100px, 5px)
20 (shared px cancels)
math.div(100px, 5)
20px
math.div(100px, 5s)
Complex unit — modern Dart Sass often emits calc(20px / 1s)
math.div(24px, 16px)
1.5 (unitless line-height ratio)
Docs vs current CSS.
Official docs historically show 20px/s for math.div(100px, 5s). Current Dart Sass may serialize that as calc(20px / 1s). Trust the compiled CSS from your compiler.
Shared units cancel; leftover units stay on the result.
Slash for CSS lists is different — use list.slash when needed.
Dart Sass 1.33+ via @use "sass:math".
One line: when two Sass numbers must be divided, call math.div($number1, $number2).
Practice
Compile Notes
Practical checklist:
checklist.txt
1. @use "sass:math"
2. Call math.div($a, $b) instead of $a / $b
3. Expect shared units to cancel
4. Keep CSS slash lists separate (font, list.slash)
5. Check compiled CSS for complex units (may be calc())
Frequently Asked Questions
math.div($number1, $number2) divides the first number by the second. Shared units cancel. Examples: math.div(1, 2) is 0.5; math.div(100px, 5px) is 20; math.div(100px, 5) is 20px. Dividing mixed unit families may serialize as calc() in modern Dart Sass.
Add @use "sass:math"; then call math.div($a, $b). Requires Dart Sass 1.33.0 or newer for the math.div API documented on sass:math.
Slash / in Sass is ambiguous (division vs CSS separators like font shorthand). Division with / is deprecated. Prefer math.div() for clear, future-safe division.
Units that appear in both numbers cancel. Units only in the first stay in the numerator; units only in the second move to the denominator. That is why 100px / 5px becomes unitless 20, while 100px / 5 stays 20px.
No. math.div() is the recommended modern division helper. Official docs warn that it still mirrors some legacy / behaviors (including string concatenation) for compatibility, and that string-slash behavior should not be used in new stylesheets.
Built-in modules with @use need Dart Sass. math.div() itself is available since Dart Sass 1.33.0. LibSass and Ruby Sass do not provide sass:math the same way.