Typography: Factors that dictate hierarchy.
--
Font size is often associated with hierarchy. But using a lot of font sizes will make our UI look amateur. In this article, we will see the factors that help us bring hierarchy to any design with simple steps.
Disclaimer: This article is best viewed in desktop mode. If you are reading this on a mobile screen, you can tilt your phone to landscape mode.
Let's look at those factors one by one. We will use this below HTML with all default styling reset.
No styles
With no styles, the above HTML looks like this.
Font size
Let’s add
24px
forh1
18px
forh2
16px
forp
.
Font weight
Let’s add,
800
font-weight forh1
700
font-weight forh2
Font color
The titles can be emphasized more by de-emphasizing the paragraphs.
- Change the
p
text from black to dark gray.
Spacing
Let's add,
8px
margin-bottom for headings16px
margin-bottom for paragraphs.
Why the difference? Proximity! Related things should stay together. In the below example, the headings stay closer to their paragraphs.
Max Width
Let's add,
max-width: 32rem
to the layout.
That is it. It is much more organized and readable.
Takeaways
- Font size, font weight, font color, spacing, and layout sizing can make a vast improvement with little effort.
- Having limited values for these factors ensures consistency throughout the design.
This is how the HTML looks in the end with the tailwind CSS classes that apply the above styles.
It's beautiful. I’ve looked at this for five hours now.
Thank you. See you next time.