snipt

Ctrl+h for KB shortcuts

CSS

Font sizing with rem

1
2
3
4
5
/** http://snook.ca/archives/html_and_css/font-size-with-rem **/

html { font-size: 62.5%; } 
body { font-size: 14px; font-size: 1.4rem; } /* =14px */
h1   { font-size: 24px; font-size: 2.4rem; } /* =24px */
https://snipt.net/embed/2d46f48ba7dd01cfbafc62478450f877/
/raw/2d46f48ba7dd01cfbafc62478450f877/
2d46f48ba7dd01cfbafc62478450f877
css
CSS
5
2019-06-27T06:00:30
True
False
False
/api/public/snipt/42685/
font-sizing-with-rem-1
<table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><a href="#L-1">1</a> <a href="#L-2">2</a> <a href="#L-3">3</a> <a href="#L-4">4</a> <a href="#L-5">5</a></pre></div></td><td class="code"><div class="highlight"><pre><span></span><span id="L-1"><a name="L-1"></a><span class="c">/** http://snook.ca/archives/html_and_css/font-size-with-rem **/</span> </span><span id="L-2"><a name="L-2"></a> </span><span id="L-3"><a name="L-3"></a><span class="nt">html</span> <span class="p">{</span> <span class="nb">font-size</span><span class="o">:</span> <span class="m">62.5%</span><span class="p">;</span> <span class="p">}</span> </span><span id="L-4"><a name="L-4"></a><span class="nt">body</span> <span class="p">{</span> <span class="nb">font-size</span><span class="o">:</span> <span class="m">14px</span><span class="p">;</span> <span class="nb">font-size</span><span class="o">:</span> <span class="m">1</span><span class="o">.</span><span class="m">4</span><span class="n">rem</span><span class="p">;</span> <span class="p">}</span> <span class="c">/* =14px */</span> </span><span id="L-5"><a name="L-5"></a><span class="nt">h1</span> <span class="p">{</span> <span class="nb">font-size</span><span class="o">:</span> <span class="m">24px</span><span class="p">;</span> <span class="nb">font-size</span><span class="o">:</span> <span class="m">2</span><span class="o">.</span><span class="m">4</span><span class="n">rem</span><span class="p">;</span> <span class="p">}</span> <span class="c">/* =24px */</span> </span></pre></div> </td></tr></table>