aboutsummaryrefslogtreecommitdiff
path: root/build/character-unit/index.html
diff options
context:
space:
mode:
Diffstat (limited to 'build/character-unit/index.html')
-rw-r--r--build/character-unit/index.html43
1 files changed, 29 insertions, 14 deletions
diff --git a/build/character-unit/index.html b/build/character-unit/index.html
index 74de90b..ce26393 100644
--- a/build/character-unit/index.html
+++ b/build/character-unit/index.html
@@ -1,43 +1,58 @@
<!doctype html>
-<html lang="en" id="top">
+<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="icon" href="data:,">
<title>CSS Character Unit</title>
- <link href="https://bt.ht/atom.xml" type="application/atom+xml" rel="alternate" title="Atom feed for blog posts" />
- <style>*{box-sizing:border-box;}body{font-family:sans-serif;margin:0 auto;max-width:650px;padding:1rem;}img{max-width:100%;}pre{overflow:auto;}table{text-align:left;width:100%;}</style>
+ <link href="/atom.xml" type="application/atom+xml" rel="alternate" title="Atom feed for blog posts" />
+ <link href="/rss.xml" type="application/rss+xml" rel="alternate" title="RSS feed for blog posts" />
+<style>*{box-sizing:border-box;}body{font-family:sans-serif;line-height:1.33;margin:0 auto;max-width:650px;padding:1rem;}img{max-width:100%;}pre{border:1px solid;overflow:auto;padding:5px;}table{text-align:left;width:100%;}.footnotes{font-size:90%;}</style>
</head>
<nav>
- <a href="#menu">Menu &darr;</a>
+ <a href="#menu">Menu &darr;</a>
</nav>
<main>
-<h1>CSS Character Unit</h1>
+<h1 id="css-character-unit">CSS Character Unit</h1>
+
<p>2019-04-23</p>
+
<p><em>When it comes to proper readability with large portions of text</em>, the golden standard is to have no more than <a href="http://webtypography.net/2.1.2">75 characters per line</a>. This is easy to achieve in the world of print but on the responsive, ever-changing web - statically defined typography becomes a little more difficult.</p>
+
<p>You could go through the long process of setting up media queries for every possible screen size, adjusting text size and padding accordingly - but there is a <em>better way</em>.</p>
-<h2>Introducing character units</h2>
-<p>By setting your main containers or text elements with the CSS character unit (<code>ch</code>), you need to set the character length only once. Let's look at a simple example for reference.</p>
-<p>Let's say you have an article which will fill the entire length of the screen. Something like this:</p>
-<pre><code>&lt;div class=&quot;container&quot;&gt;
- &lt;p&gt;Reprehenderit aliqua in quis eiusmod ea culpa aliquip. Velit duis est irure voluptate occaecat labore laborum ut pariatur ex veniam deserunt esse est. Esse sunt exercitation id reprehenderit deserunt elit commodo sit ullamco amet commodo magna consequat. Excepteur voluptate tempor consectetur eu aliqua aliquip laboris aliquip veniam excepteur labore.&lt;/p&gt;
- &lt;p&gt;Voluptate excepteur sint magna ipsum occaecat irure sit. In occaecat excepteur in id ullamco id est incididunt irure et. Consectetur veniam exercitation occaecat exercitation labore nulla excepteur irure ex anim. Commodo sint anim non ad excepteur exercitation eiusmod Lorem nisi. Tempor ut ipsum do adipisicing dolore.&lt;/p&gt;
-&lt;/div&gt;
+
+<h2 id="introducing-character-units">Introducing character units</h2>
+
+<p>By setting your main containers or text elements with the CSS character unit (<code>ch</code>), you need to set the character length only once. Let&#8217;s look at a simple example for reference.</p>
+
+<p>Let&#8217;s say you have an article which will fill the entire length of the screen. Something like this:</p>
+
+<pre><code>&#60;div class="container"&#62;
+ &#60;p&#62;Reprehenderit aliqua in quis eiusmod ea culpa aliquip. Velit duis est irure voluptate occaecat labore laborum ut pariatur ex veniam deserunt esse est. Esse sunt exercitation id reprehenderit deserunt elit commodo sit ullamco amet commodo magna consequat. Excepteur voluptate tempor consectetur eu aliqua aliquip laboris aliquip veniam excepteur labore.&#60;&#47;p&#62;
+ &#60;p&#62;Voluptate excepteur sint magna ipsum occaecat irure sit. In occaecat excepteur in id ullamco id est incididunt irure et. Consectetur veniam exercitation occaecat exercitation labore nulla excepteur irure ex anim. Commodo sint anim non ad excepteur exercitation eiusmod Lorem nisi. Tempor ut ipsum do adipisicing dolore.&#60;&#47;p&#62;
+&#60;&#47;div&#62;
</code></pre>
+
<p>With this structure, you might normally set the default <code>max-width</code> property with your desired maximum width (whatever you believe is the best reading length):</p>
+
<pre><code>.container {
max-width: 38em;
}
</code></pre>
-<p>This works - but it isn't ideal. Time for character units to save the day! You will still target the <code>max-width</code> property but this time we set it to use the <code>ch</code> value like so:</p>
+
+<p>This works - but it isn&#8217;t ideal. Time for character units to save the day! You will still target the <code>max-width</code> property but this time we set it to use the <code>ch</code> value like so:</p>
+
<pre><code>.container {
max-width: 66ch;
}
</code></pre>
+
<p>This setting makes sure content will not exceed more than 66 characters per line, making for a better reading experience with little effort.</p>
-<h2>Browser support</h2>
+
+<h2 id="browser-support">Browser support</h2>
+
<p>The character unit attribute has pretty great support - even partial IE11! Check out the supported browsers <a href="https://caniuse.com/#feat=ch-unit">here</a>.</p>
<footer role="contentinfo">
<h2>Menu Navigation</h2>