Discover how a few simple classes can make your website text look perfect on any screen!
Why Font size and scaling in Tailwind? - Purpose & Use Cases
Start learning this pattern below
Jump into concepts and practice - no test required
Imagine you are designing a website and want the text to look good on both small phones and large desktop screens. You try setting font sizes by guessing pixel values for each device.
Manually picking fixed font sizes means text can look too small on big screens or too large on small ones. You must change many values for every device, which is slow and confusing.
Font size and scaling with Tailwind lets you use simple classes that adjust text size automatically for different screen sizes. This saves time and keeps your site readable everywhere.
p { font-size: 14px; }
@media (min-width: 768px) { p { font-size: 18px; } }<p class="text-sm md:text-lg">Hello world</p>
You can create websites that look great and are easy to read on any device without rewriting styles for each screen size.
Think of a blog where the text is comfy to read on your phone during a commute and also looks perfect on a big desktop monitor at home.
Manually setting font sizes for each device is slow and error-prone.
Tailwind's font size and scaling classes adjust text automatically for different screens.
This makes your website readable and beautiful everywhere with less work.
Practice
Solution
Step 1: Understand Tailwind font size naming
Tailwind usestext-xsfor extra small font size.Step 2: Match the class to the size
Among the options, onlytext-xsmeans extra small.Final Answer:
text-xs -> Option AQuick Check:
Extra small font = text-xs [OK]
- Confusing text-xs with text-base or text-lg
- Thinking text-3xl is small instead of large
- Assuming text-base is the smallest size
Solution
Step 1: Recall Tailwind font size scale
Tailwind font sizes go up totext-9xlfor very large text.Step 2: Identify the largest size option
Among the options,text-9xlis the largest size available.Final Answer:
text-9xl -> Option CQuick Check:
Largest font size = text-9xl [OK]
- Choosing text-2xl thinking it's the largest
- Confusing text-sm as large
- Using text-base which is default size
<p class="text-lg">Hello</p>
Solution
Step 1: Understand the class
The classtext-lgtext-lgin Tailwind means large font size, bigger than base.Step 2: Match the size description
Among the options, "Large font size" best matchestext-lg.Final Answer:
Large font size -> Option AQuick Check:
text-lg = Large font size [OK]
- Thinking text-lg is medium or small
- Confusing text-lg with text-xl or text-base
- Ignoring the class and guessing default size
<p class="?">Responsive Text</p>
Solution
Step 1: Understand Tailwind responsive prefixes
Tailwind uses prefixes likemd:to apply styles on medium screens and up.Step 2: Choose smaller text by default and larger on medium screens
text-sm md:text-lgmeans small text on mobile and large text on medium+ screens.Final Answer:
text-sm md:text-lg -> Option BQuick Check:
Mobile small, desktop large = text-sm md:text-lg [OK]
- Reversing sizes for mobile and desktop
- Using wrong breakpoint prefixes
- Not using responsive prefixes at all
<h1 class="?">Scaling Heading</h1>
Solution
Step 1: Identify scaling from small to very large
We want text starting small on mobile, then bigger on medium, and very large on large screens.Step 2: Check each option's size progression
text-sm md:text-4xl lg:text-7xlscales fromtext-sm(small), totext-4xl(large), totext-7xl(very large), matching the requirement.Final Answer:
text-sm md:text-4xl lg:text-7xl -> Option DQuick Check:
Small to very large scaling =text-sm md:text-4xl lg:text-7xl[OK]
- Choosing options with small max sizes
- Not increasing size enough on larger screens
- Using sizes that start too large on mobile
