🍋
Menu
How-To Beginner 1 min read 250 words

Responsive Typography: Fluid Text Sizing Strategies

Fixed font sizes don't adapt to different screen sizes. Learn how to implement fluid typography that scales smoothly between mobile and desktop viewports.

The Problem with Fixed Sizes

Using a single font-size for all screen widths creates readability issues. Text sized for desktop becomes too large on mobile, consuming valuable viewport space. Text sized for mobile becomes too small on large monitors, forcing unnecessary scrolling.

The clamp() Approach

CSS clamp() sets a minimum, preferred, and maximum value in one declaration:

h1 { font-size: clamp(1.75rem, 4vw + 0.5rem, 3rem); }
p  { font-size: clamp(1rem, 1.5vw + 0.5rem, 1.25rem); }

This creates text that scales with viewport width while staying within readable bounds. The middle value (preferred) uses viewport units combined with a fixed value for smoother scaling.

Type Scale Ratios

A type scale is a set of harmonious font sizes based on a ratio. Common ratios: 1.25 (Major Third), 1.333 (Perfect Fourth), 1.5 (Perfect Fifth). Starting from a base size of 1rem, multiply by the ratio for each level: 1rem, 1.25rem, 1.563rem, 1.953rem, 2.441rem.

Line Height Considerations

Larger text needs tighter line height. A body text line-height of 1.5-1.7 works well, but headings should use 1.1-1.3. Line length (measure) should stay between 45-75 characters per line for optimal readability — adjust container max-width accordingly.

Testing Fluid Typography

Test at the minimum, maximum, and several intermediate viewport widths. Check that text doesn't become too small on narrow screens or too large on ultra-wide monitors. Verify that line lengths stay readable at all sizes. Test with browser zoom levels from 50% to 200% to ensure the typography remains coherent.

Outils associés

Formats associés

Guides associés