font size scale
I've been experimenting with the method (found at https://every-layout.dev/rudiments/modular-scale/). It aims to create a perfect balance between font sizes by utilizing the previous size and multiplying by a ratio to decide the next size up. The ratio is decided based off of the root font size and the line height. In this case the root font size is
1rem
and the line height is 1.5
so the ratio is 1.5
.
The scale looks something like this:
Taking the fact that there's a pattern in the scale which creates the balance between sizes, if i wanted to use clamp
to adjust my font-sizes depending on the viewport size, how would i create a similar pattern and balance with the rem
and vw
properties for the preferred size?
Let's say my primary header looks something like this:
would my secondary header look something like this?
i'd appreciate any help, thanks in advance.4 Replies
I honestly don't put any stock in those so-called modular scale formula. If design could be encapsulated with a simple formula it'd be easier to do!
I mean,
1rem
, 1.5rem
, 2.25rem
, 3.375rem
, 5.0625rem
, 7.59375rem
is just a weird "scale". It's an exponential growth. Whereas the default h1
for most browsers is only 2em
…that's smaller than half of your custom font sizes! Not to mention that both h5
and h6
have font sizes smaller than 1em
and your scale doesn't have that—unless you expect "normal" font size to be 2.25rem
(as h4
is the same font size as the base text).
Before going and making such a sweeping change you should stop and ask yourself what problem you're having that this solves. If you want fluid type just use a simple clamp
function to set the base font size and then set everything else based on that.
A fairly simple code example:
Since all font sizes are either inherited or em
-based (all browser-based font sizes are in em
and not rem
) that should cascade down to all elements for you.Ah that makes a lot of sense actually, thank you.
In regards to the
h5
and h6
font sizes, if you divide by the ratio instead you would get a font size smaller than 1em
, I believe it’d look something like this which results in 0.666em
Based off of what you said I have a few questions if that’s okay:
1. what’s a browser font size?
2. why would you recommend they’re set in em
if we’re usually taught that font sizes should be in rem
? And how would you combat value stacking doing it this way?
3. how would you recommend calculating the preferred value for the clamp?1. what’s a browser font size?Default browser fonts sizes are as follows:
2. why would you recommend they’re set inBeginners are taughtem
if we’re usually taught that font sizes should be inrem
? And how would you combat value stacking doing it this way?
rem
to avoid issues with not understanding how em
cascades down and "stacks" as you put it. using rem
for font size is "easy mode", as it were, because you know exactly what you're getting out of it. But issues arise if you set, say, a font size of 1.5em
on a div and then put a rem
-based header in there—suddenly the font size is the same size as the headers!
3. how would you recommend calculating the preferred value for the clamp?I gave you my starting point, above: Depending on the use case of your site, your chosen font face, and the target device you expect most users to use you'll want to adjust the middle number. While you can adjust the first I would not recommend it—1em is whatever default the user has chosen (even if they didn't change the default it's still a choice to use that) and going any smaller will be annoying at the very least. The last number can be adjusted, too, of course. But I find that it's a great starting point. Here's a great article on choosing font sizes. And one on why type scale is silly.
Ah that’s all been very helpful, I appreciate it, and I’ll check out those articles!