Essential CSS
JavaScript Roadmap
Learn JavaScript
Mastering Web Typography
Practical Astro
Understanding Async JS
Unorthodox Tailwind
API Masterclass
Build and Deploy
The Beginner Freelancer
Real World Node
Profile Billing Logout
Unorthodox Tailwind
Lesson Plan
  1. Introduction
    1. Introduction
    2. What Tailwind brings to the table
    3. Tailwind: The Good and The Bad
    4. The First and Most Important Step
    5. Simple Unorthodox System
    6. The System I Use
  2. Tailwind Fundamentals
    1. Introduction
    2. Installing Tailwind
    3. Using Tailwind utilities
    4. Understanding Tailwind’s utility system
    5. Understanding Tailwind values
    6. Understanding Tailwind variants
  3. Unorthodox Fundamentals
    1. Introduction
    2. Making Simple Tailwind Utilities
    3. Components vs Utilities
    4. Specificity, Cascade, and CSS Layers
    5. Debugging Tailwind Styles
    6. Composable Utility System
    7. Create lots of components
  4. Layouts System
    1. Tailwind is great for layouts
    2. Four Types of Layouts
    3. Building Shell Layouts
    4. Building Macro Layouts
    5. Better Responsive Variants
    6. A collection of maximum widths
    7. A note on grid wrappers
    8. Working with sections
    9. Building Micro Layouts
    10. Positioning Layouts
  5. Typography System
    1. Introduction
    2. A system for using multiple typefaces
    3. Tailwind's font-size system
    4. Finding your font-size system
    5. My font-size system
    6. A simple responsive typography system
    7. The main body
    8. Vertical rhythm
  6. Theming System
    1. Introduction
    2. Tailwind's colour system
    3. The pigment system
    4. Tailwind's gradient system
    5. A friendlier gradient system
    6. Handling SVG fill and stroke
    7. Improving Tailwind's colour palette
    8. A simple way to theme
  7. Useful Tools
    1. Introduction
    2. Making functional utilities
    3. Custom variants
    4. Scaffolding tools
    5. Extending Tailwind
  8. Effects System
    1. Introduction
    2. Vertical text
    3. Strikethrough text
    4. Text stroke
    5. Highlighting text
    6. Nicer shadows
    7. Transitioning shadows
    8. Drop shadows
    9. Dark mode tricks
    10. Gradient borders
    11. More effects to explore
  9. Putting Everything Together
    1. The Unorthodox Tailwind process
    2. The 4 systems combined
    3. Create components liberally
    4. Advanced tips
    5. My CSS Structure
    6. A Cheatsheet
    7. Consolidating your thoughts
    8. Parting words

Vertical rhythm

3m:52s

No discussion of typography will be complete without the inclusion of vertical rhythm. So let’s talk about that — how to use it, and the principles behind it.

Vertical Rhythm in a nutshell

Vertical rhythm is basically the idea that you should align text based on the amount of line-height. When text is always aligned by this value, the text becomes orderly and uniform, and hence, is supposed to be nicer.

Typically, in print, the text sits on the baseline grid, while on the web, we do not have a baseline, but we have line-height, so text floats between lines.

Baseline grid in print
Baseline grid in print
Baseline grid on the web
Baseline grid on the web

It is very difficult to create a perfect vertical rhythm on the web because line-height is split evenly above and below the font. To make headers sit on the baseline grid, a lot of calculations are required.

The question isn’t whether this is correct or not, but whether it is worth the effort to do so. (Most of the time, it is not.)

The real reasons behind vertical rhythm

Vertical rhythm is a rule derived from repetition and alignment.

  1. When something is repeated more often, it is more familiar so it looks more right. In this case, we are only repeating the white space.
  2. When something is aligned, it is more orderly, less chaotic. So people fall into a rhythm that they can flow with.

So it doesn’t matter what whitespace value you repeat. As long as you repeat it consistently, it will look nice enough. (Maybe not for getting awards, but good enough for most websites.)

Horizontal rhythm

Horizontal rhythm is just as important as vertical rhythm for the same reasons — repetition and alignment.

If you apply the same horizontal and vertical rhythm, the whole site looks uniform. If you don’t, the whole site looks a little bit chaotic.

No right, no wrong. Depends on the field you are trying to create.

The correct rhythm

There is no real consensus but I have seen points of view commonly converging into two values:

  • 1em - one font-size value
  • 1lh - one line-height

I used to think that 1lh was the correct answer (because that’s the rule!), but a print designer later told me that 1lh seems to be too much spacing between paragraph elements.

That got me confused for a long time.

Eventually, I understood that both values are correct (because you repeat them both on the page a lot). So you just have to be consistent and mindful about what context they are being used for.

My go-to simple rhythm

I use 1lh for longform text and 1em (or 1rem) for other contexts.

Because:

  • 1em is good for most other contexts. It keeps things tight.
  • 1lh is generally too much space, but it excels in longform text because it lets users rest on new paragraphs (1em is too tight, so I disagreed with that print designer eventually).

To see why 1lh is good for longform, click this button here — it’ll switch the margins between paragraphs on this page so you can see the difference yourself.

Current rhythm: 1lh

Try it. You’ll see that:

  • 1em feels like a whole block of continuous text
  • 1lh allows for some breathing room as you’re reading.

Again, no right, no wrong, depending on how long your text is and what you are trying to create.

And that brings us to an interesting question.

The base rhythm unit

Since there is no definite answer to the right rhythm, you can explore and see what you prefer! One way to make this easy is to change the base rhythm unit that Tailwind provides you with. (It is called --spacing).

  • By default, Tailwind sets one --spacing value to be 0.25rem.
  • That is why 4 --spacing is 1rem.
  • But you can also change the unit to 0.25rlh if you want to experiment with line-height base values.
@theme {
--spacing: 0.25rlh;
}

This is completely optional — but you might find that suddenly there is too much spacing everywhere! So much that you have to use 0.75rlh over 1rlh for most spaces.

Warning: do not switch between rem and rlh in the middle of a project, because all of the white space will go out of whack. Choose one and use it for the entirety of that site.

That’s all I want to share with you about typography in Tailwind!