REM vs. EM – The Great Debate
I rarely use rem since I only stopped needing to support IE8 recently. Instead, to deal with the pain of em calculations I use these sass mixins (feel free to use; license CC0 <a href="https:&#x2F;&#x2F;wiki.creativecommons.org&#x2F;wiki&#x2F;CC0" rel="nofollow">https:&#x2F;&#x2F;wiki.creativecommons.org&#x2F;wiki&#x2F;CC0</a>) (below is my first attempt at &quot;sassdoc,&quot; which I happened to discover while preparing this comment):<p><pre><code>    $current-font-size: 16;
    
    &#x2F;&#x2F; Remove the units from a value (pretty sure someone else wrote this originally)
    @function strip-units($number) {
        @if unit($number) == &#x27;&#x27; {
            @return $number;
        }
        @return $number &#x2F; ($number * 0 + 1);
    }
    
    &#x2F;&#x2F;&#x2F; Sets font-size and line-height using percentage and unitless values respectively, with support for nesting.
    &#x2F;&#x2F;&#x2F; @param {Number} $new-font-size - Desired new font size in pixels (units ignored)
    &#x2F;&#x2F;&#x2F; @param {Number} $new-line-height - New line height in pixels (units ignored)
    &#x2F;&#x2F;&#x2F; @param {Number} $context-font-size - Current font size where you&#x27;re including this mixin, if it isn&#x27;t the global $current-font-size
    @mixin font-scale($new-font-size, $new-line-height:null, $context-font-size:$current-font-size) {

        &#x2F;&#x2F; Set the font size
        $context-font-size: strip-units($context-font-size);
        $new-font-size: strip-units($new-font-size);
        $font-ratio: $new-font-size &#x2F; $context-font-size;
    
        font-size:$font-ratio * 100%;
    
        &#x2F;&#x2F; Set the line height
        @if $new-line-height != null {
            $new-line-height: strip-units($new-line-height);
            &#x2F;&#x2F; Honestly don&#x27;t remember why the &quot;+ 0.0001&quot; here:
            $line-ratio: $new-line-height &#x2F; $new-font-size + 0.0001;

            line-height:$line-ratio;
        }
    
        &#x2F;&#x2F; Include nested content with global $current-font-size set to the new value
        $last-cfs: $current-font-size;
        $current-font-size: $new-font-size !global;
    
        @content;
    
        &#x2F;&#x2F; Reset the global $current-font-size to what it was before
        $current-font-size: $last-cfs !global;
    }
    
    &#x2F;&#x2F;&#x2F; Convert a pixel length to ems at the current (or given) font size
    &#x2F;&#x2F;&#x2F; @param {Number} $px-length - Length in pixels (units ignored)
    &#x2F;&#x2F;&#x2F; @param {Number} $font-size - Current font size in px, if it isn&#x27;t the global $current-font-size (units ignored)
    @function ems($px-length, $font-size:$current-font-size) {
        $px-length: strip-units($px-length);
        $font-size: strip-units($font-size);
        @return ($px-length &#x2F; $font-size)*1em;
    }
</code></pre>
(Those are modified slightly and haven&#x27;t been tested in this exact form.) This lets me do, for example:<p><pre><code>    .title {
        
        &#x2F;&#x2F; Make the text in .title 112.5% (18 ÷ 16) with a line-height of 1.22 (22 ÷ 18)
        @include font-scale(18, 22) {

            &#x2F;&#x2F; Give it 15 pixels of padding using em units
            padding:ems(15);
            
            &#x2F;&#x2F; Make the text of a .subtitle inside a .title 14px (112.5% × (14 ÷ 18) = 87.5%)
            &#x2F;&#x2F; (line-height remains 1.22 in this case, working out to 17.11px)
            .subtitle {
                @include font-scale(14);
                
                &#x2F;&#x2F; Give .subtitle 5 pixels of padding, but instead of nesting
                &#x2F;&#x2F; the mixin again, I&#x27;ll just tell ems() that the current
                &#x2F;&#x2F; font size is 14 directly.
                padding:ems(5, 14);
            }
            
        }
    }
</code></pre>
The nesting isn&#x27;t attractive and `ems(15)` is a little more typing than `15em` (though not more than `(15&#x2F;18)×1em`), but I think just using em for everything reduces some cognitive load.<p>It also lets you do some tricks, like you can set the root element of some component to `font-size:(16&#x2F;1024)*100vw` and it&#x27;ll have a &quot;normal&quot; size when the viewport is 1024px wide but scale up smoothly in every dimension when the viewport is larger (and down when smaller). And you can still scale the whole page, including that component, by changing the font-size of html&#x2F;body.<p>Thus far I only use rem when I need to override something for an inner element, like if a piece of the aforementioned vw-sized component gets too small when the viewport is less than 640, I would set the font-size for just that piece in a media query using rem, allowing the rest of the component to continue to scale down.