Preventing Overly Large Text
What you'll learn: How to use the maximum value in clamp() to keep text readable on ultra-wide screens.
The Problem with Unlimited Scaling
When you use fluid typography with viewport units, text grows as the screen gets wider. While this works beautifully for most devices, ultra-wide monitors (like 4K displays or 34" ultrawide screens) can make your text enormous—sometimes uncomfortably large and harder to read.
Think of it like zooming in on a photo indefinitely: at some point, bigger isn't better—it just becomes awkward.
The Solution: Set a Maximum Ceiling
The clamp() function takes three values: minimum, preferred (fluid), and maximum. The third value—the maximum—acts as a safety cap, preventing your text from growing beyond a comfortable reading size.
Here's how to apply it:
body {
/* Won't grow larger than 24px, even on massive screens */
font-size: clamp(16px, 2vw, 24px);
}
h1 {
/* Caps at 60px for ultra-wide displays */
font-size: clamp(32px, 5vw, 60px);
}
In the first example, even if 2vw would calculate to 40px on a huge screen, the font will stop scaling at 24px. The maximum value overrides the viewport-based calculation.
Choosing Good Maximums
- Body text: Typically cap between
20px–24pxfor comfortable reading - Headings: Can go larger, but avoid exceeding
60–80pxunless intentional - Test on wide viewports: Preview at 1920px, 2560px, or wider to see the cap in action
The maximum value ensures your carefully crafted typography doesn't become a giant, awkward mess on large displays.
Key Takeaway: Always include a sensible maximum value in clamp() to prevent text from scaling too large on ultra-wide screens, maintaining readability across all device sizes.