Respecting Your Users' Fonts
Published: 2021-07-19 00:22:52

---
title: Respecting Your Users' Fonts
published: true
date: 2021-06-23 12:58:00 UTC
tags: 
canonical_url: https://kevincox.ca/2021/06/23/respect-user-fonts/
---

<main><p>I recently changed the style of this blog. It was a trivial change, but the rationale is interesting. I removed the following CSS.</p>
<div><pre><code><span>body</span> <span>{</span>
	<span>font-size</span><span>:</span> <span>1.3em</span><span>;</span>
<span>}</span>
</code></pre></div>
<p>All the text on this blog is sized relatively based on the browsers’ default size. This is very easy to do by using the <a href="https://developer.mozilla.org/en-US/docs/Learn/CSS/Building_blocks/Values_and_units#relative_length_units"><code>em</code> or <code>%</code> CSS units</a>. Both of which are relative to the size of the text in the parent element. For example, a heading can be <code>1.2em</code> or <code>120%</code> to be a bit larger than the text in the parent element. Alternatively you can also use <code>rem</code>, which is relative to the size of text in the root element instead of the parent element.</p>
<p>The main advantage is that it respects the user’s configuration. A user who likes bigger text (maybe they have bad vision) can just adjust their font size and the website will react. Previously I was bumping the font size over the user’s default because it seems that most operating systems and browsers default to quite small text. My relative bump was undoing this perceived “mistake” in the browser configuration. This isn’t completely unjustified, it makes sense to have larger text on a reading-focused site that has little superfluous elements consuming space. This highlights a limitation with a single default text size. A dense UI with short labels would likely be better suited with smaller text. Whereas long-form content cares little about how much can fit on one screen, instead valuing ease of reading above all else. The browser’s single default size is unable to encapsulate this nicely.</p>
<p>I can’t find an authoritative answer on what exactly the default font size means. But most discussions I have found seem to think that it should be suitable for long-form text. For example, <a href="https://nicolas-hoizey.com/articles/2016/03/02/people-don-t-change-the-default-16px-font-size-in-their-browser/">this article</a> (which ironically adjusts the default font size) found that a number of devices use a large default font size to provide a better reading experience.</p>
<p>At the end of the day there is no perfect solution. So I decided that it’s better to punish those with misconfigured browsers and operating systems than to punish those who configured their systems correctly (even if the former group is likely larger). I might change my mind again in the future, but for now this seems like the best choice.</p>
<p>Currently, my website uses the user’s defaults wherever possible. I understand that for some use cases (like games) it makes sense to have exciting and unique fonts and some companies feel it is important to push their “brand”. But for this site—which is just focused on sharing information—following the user’s preference seems like the right thing to do and is the route I try to take where possible. For example, this site also uses the user’s default font-face and the user’s preferred colour scheme.</p>
<p>Unfortunately, the web still forces me to make a lot of styling decisions myself. It would be great if I could ask the browser to apply much more default CSS, conceding most stylistic decisions to something under the user’s control. This would be much like <a href="https://blog.mozilla.org/en/products/firefox/reader-view/">“Reader Mode”</a>, but automatically applied upon visiting supporting sites. But that is a topic for another day…</p>